Metadata-Version: 2.1
Name: labml-db
Version: 0.0.2
Summary: ORM for JSON/YAML file based DB
Home-page: https://github.com/lab-ml/db
Author: Varuna Jayasiri, Nipun Wijerathne
Author-email: vpjayasiri@gmail.com, hnipun@gmail.com
License: UNKNOWN
Project-URL: Documentation, https://lab-ml.com/
Keywords: database,json,yaml
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/x-rst
Requires-Dist: pyyaml (>=5.3.1)

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

LabML DB
========

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

You can install this package using PIP.

.. code-block:: console

    pip install labml_db


Example
^^^^^^^

.. code-block:: python

    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

.. code-block:: python

    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'))
    ])


