SQL (Alchemy)
Type
Database Table
= GraphQL Type
Table | Model | Type
import dbcontroller as dbc
sql = dbc.Controller(sql="sqlite:///example.db")
# Types
@sql.model
class User:
name: str
notes: dbc.text
meta: dbc.json
disabled: bool = False
Manager
C.U.D — Examples
Reading | Querying (One-Record)
Reading | Querying (Multiple-Records)
results = await table.all()
query = (
table.where("name", "contains", "jane")
| table.where("name", "contains", "joe")
)
results = await table.find(query, page=1, limit=100, sort_by="-id")
query = {"name": "joe doe"}
results = await table.filter_by(search=query, page=1, limit=100, sort_by="-id")
search_value = "j"
columns = ["name", "notes"]
results = await table.search(columns=columns, value=search_value, page=1, limit=100, sort_by="-id")