aql¶
Staraql is a simple, modern, and composable query builder, with support for asynchronous execution of queries against multiple database backends using a unified API. aql uses modern, type annotated data structures for both table definitions and queries:
from aql import table, MysqlEngine
@table
class Contact:
id: int
name: str
email: str
query = (
Contact.select()
.where(Contact.email.like("%@gmail.com"))
.order_by(Contact.name)
.limit(5)
)
sql, params = MysqlEngine.prepare(query)
# select * from `Contact` where `email` like ? order by `name` asc limit 5