A Python database layer

One data model.
Many ways
to use it.

Declare your tables, relationships and calculations once. Use them in queries and business logic, with SQL you can inspect.

Python 3.11+PostgreSQL & SQLiteApache 2.0
asqueel shell ./console-demoPython
# db is ready when the console opens.
region = db.table('invc.region')
region.insert({
    'code': 'NO',
    'name': 'North',
})
db.commit()

A plain Python dictionary. An explicit commit.

query = region.query(
    columns='$code, $name',
    where='$code = :code',
    code='NO',
)
rows = query.fetch()

Column references in SQL. Values bound separately.

print(query.sqltext)
SELECT "t0"."code" AS "code",
"t0"."name" AS "name"
 FROM "invc"."invc_region" AS "t0"
WHERE ("t0"."code" = :code)

SQLite output from the downloadable example.

[dict(row) for row in rows]
[{'code': 'NO', 'name': 'North'}]

Rows support name and position access. Use dict(row) for a dictionary.

Describe once. Keep relationships and formulas in the model.

Read the SQL. Inspect a query before executing it.

Own the transaction. Choose when to commit or roll back.

From a definition to an application

The model does more
than name your tables.

A customer's name, an invoice calculation, a relation between tables: give each a place in the model and reuse it.

01 / DECLARE

Give your data
a shared vocabulary.

Write a Python recipe for packages, tables and columns. Add keys, relationships and calculated values where they belong.

Read a model recipe →

02 / QUERY

Follow the relations.
Keep the SQL.

Use $column and @relation.column in expressions. Let Asqueel resolve the model names and bind your values.

Explore query syntax →

03 / WRITE

Work with records.
Control the changes.

Insert, update and delete through table objects. Learn the write cycle, hooks and the boundary of each transaction.

Follow a write →

Meet Asqueel Migration

Describe the schema.
Review the difference.

A separate, ORM-independent engine compares the database you have with the structure you need. Inspect the generated SQL, apply a reviewed plan and check the result.

Desired schemaJSON · XML · Asqueel model
Live databaseIntrospected structure
Compare → Generate SQL
Review → Apply → Verify

Learn by following the code

One invoicing model.
A complete learning path.

From your first database object to relations, queries, writes and migrations. Read the course or watch the first three narrated lessons.

34lessons
6modules
293scenes

Based on the development API. Compatibility notes.

01

Orientation

Meet the model. Build your first database object.

02

The model

Tables, relations, calculated columns and configuration.

03

Reading data

Write queries, bind values and choose the result shape.

04

Writing data

Understand changes, triggers and relation actions.

05

Transactions & operations

Control connections, migrations and application integration.

06

Other Python ORMs

Compare the concepts and make an informed choice.

Start with something
you can inspect.

Use the CLI to validate your configuration, plan a migration or open a Python console with your database ready.

asqueel check ./console-demo
asqueel db plan ./console-demo
asqueel db apply ./console-demo
asqueel shell ./console-demo

The console is standard Python. Your db object is already available. Build a query, inspect its SQL, fetch rows, or insert a record.

Writes are saved with db.commit(). Leaving the console rolls back pending work.