Table¶
A convenience wrapper bound to a single validated table name.
Table now mirrors the database query surface anywhere a table-bound version makes sense.
Table.select(columns=None, where=None, params=None, group_by=None, having=None, order_by=None, limit=None, offset=None, distinct=False)¶
Return rows from the bound table.
from sqlite7 import open_db
with open_db(":memory:") as db:
db.script("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER);")
users = db.table("users")
users.insert_many(
[
{"id": 1, "name": "Ada", "age": 36},
{"id": 2, "name": "Grace", "age": 37},
{"id": 3, "name": "Linus", "age": 38},
]
)
rows = users.select(
columns=["id", "name"],
where="age >= ?",
params=[36],
order_by="id DESC",
limit=2,
offset=0,
distinct=False,
)
print(rows)
Table.all(...)¶
Alias for Table.select(...) with the same arguments.
Table.get(where, params=None, columns=None, group_by=None, having=None, order_by=None, offset=None, distinct=False)¶
Return one row from the bound table using the same selection controls, with limit=1 applied automatically.