Skip to content

Version 0.2.0

Compare
Choose a tag to compare
@aminalaee aminalaee released this 17 Sep 06:34
· 25 commits to master since this release
a036942

Version 0.2.0 depends on typesystem>=0.3.0 for validation. This release changes how model fields are defined, now they are defined as a dict in the fieldsattribute of the model.

import databases
import orm


database = databases.Database("sqlite:///db.sqlite")
models = orm.ModelRegistry(database=database)


class Note(orm.Model):
    tablename = "notes"
    registry = models
    fields = {
        "id": orm.Integer(primary_key=True),
        "text": orm.String(max_length=100),
        "completed": orm.Boolean(default=False),
    }

There's no need for sync database drivers like psycopg2 for creating and destorying tables. ModelRegistry can do that now:

models.create_all()

models.drop_all()