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 `fields`attribute of the model.
python
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:
python
models.create_all()
models.drop_all()