tinydb-baseClass

a base class to tinydb


License
MIT
Install
pip install tinydb-baseClass==1.0.0

Documentation

TinyDB base

i use TinyDB ... a lot and very offen and i seam to be writeing the same functions over and over. The idea behind the small project to provide a way for devs to easly create a data modal around tinydb without the need to build a base class.

How do i use this thing

the idea is import the baseclass and then inherits into your own class.

    class MyTable(DatabaseBase):

        def __init__(self, file='ds.json', table=__name__, requiredKeys=['title']):
            super().__init__(file=file, table=table, requiredKeys=requiredKeys)


    MyTable().create({'title': 'foobar'})

This will enable to acesses the base class, you can add your own custom fuctions.

methods

Method Name attr Description
create dict this adds a new row to the database.
createMultiple list of dicts this added multiple rows
readAll returns a list obj
readById id this gets a row by the id
removeById id this removes a row by id