Skip to main content

ORM for JSON/YAML file based DB

Project description

https://badge.fury.io/py/labml_db.svg https://pepy.tech/badge/labml_db

LabML DB

LabML DB is a simple ORM database that uses JSON and YAML files.

You can install this package using PIP.

pip install labml_db

Example

from labml_db import Model, Index


class Project(Model['Project']):
    name: str
    experiments: int

    @classmethod
    def defaults(cls):
        return dict(name='', experiments=0)


class User(Model['User']):
    name: str
    projects: List[Key[Project]]

    @classmethod
    def defaults(cls):
        return dict(name='', projects=[])


class UsernameIndex(Index['User']):
    pass

You can configure it to use JSON/YAML files

Model.set_db_drivers([
    FileDbDriver(JsonSerializer(), 'User', Path('./data/user')),
    FileDbDriver(YamlSerializer(), 'Project', Path('./data/project'))
])
Index.set_db_drivers([
    FileIndexDbDriver(YamlSerializer(), 'UsernameIndex', Path('./data/UserNameIndex.yaml'))
])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labml_db-0.0.2.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

labml_db-0.0.2-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page