Skip to main content

asyncio db query generator

Project description

aql

Simple, async query library for modern Python

build status code coverage version license code style

Highlights

aql 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.

aql is still in early alpha. Not all features are available or finalized.

Define tables:

@table("objects")
class Object:
    id: PrimaryKey[AutoIncrement[int]]
    name: Unique[str]
    description: text
    created: datetime

Build queries:

query = (
    Object.select()
    .where(Object.id >= 25)
    .order_by(Object.name)
    .limit(5)
)

sql, params = SqlEngine.prepare(query)
# "select * from `objects` where `id` >= ? order by `name` asc limit 5", (25)

Execute queries:

async with connect(...) as db:
    cursor = db.execute(Object.select().where(Object.id < 100))
    async for row in cursor:
        print(f"{row.id} {row.name} {row.description}")

Simple actions:

async with connect(...) as db:
    rows = await db.get(Object, Object.id == 100)
    rows[0].description += "updated"

    await db.modify(Object, rows)

License

aql is copyright John Reese, and licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aql-0.4.0.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

aql-0.4.0-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file aql-0.4.0.tar.gz.

File metadata

  • Download URL: aql-0.4.0.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for aql-0.4.0.tar.gz
Algorithm Hash digest
SHA256 f3e3cf2f77b3c12c64742b6d051c0a4c045f3962e90ea6fe418272578c49170c
MD5 a9929b23bda8c5d2cc4a2ea6a2d05d17
BLAKE2b-256 a6e5bc33c0708a1f701a63286d81616da4d70fd3d81f61e5d883b1f112da43cb

See more details on using hashes here.

File details

Details for the file aql-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: aql-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 28.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for aql-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2147efc3d49b4740f66dc546d33fa472efddfe2189057ef1c1d2d7772c8da23
MD5 932fd7d335dc6495c4db5d16335c4cce
BLAKE2b-256 04cc83aeecc32cff43db3855897cf468897855b4292bb69b0e31c9199b070237

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page