Skip to content

Notebook (DBC)

PIP Install

Install

python -m pip install notebook "dbcontroller[testing]"

Run

python -m jupyter notebook

PDM Install

Install

pdm add notebook "dbcontroller[testing]"

Run

pdm run jupyter notebook

Initialize

import dbcontroller as dbc

sql = dbc.Controller(sql="sqlite:///example.db")

Database Controller

@sql.model(table_name="users")
class User:
    name: str
    notes: dbc.text
    meta: dbc.json
    disabled: bool = False

Load Classes (Manager)

# Init Objects
dbc.load([User])

SQLAlchemy

from sqlalchemy import create_engine

# Init Table (SQLAlchemy)
engine = create_engine(sql.url, echo=True)
sql.base.metadata.create_all(engine)

Demo


Create

await User.create([{"name": "joe doe"}, {"name": "jane doll"}])

Get-All

await User.all()