asyncio db query generator
Project description
aql
Simple, async query library for modern Python
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
Built Distribution
File details
Details for the file aql-0.4.1.tar.gz
.
File metadata
- Download URL: aql-0.4.1.tar.gz
- Upload date:
- Size: 31.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.24.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cadeddbcce962e1cba390bd71cd21f55988d4bd09c85c41adf231413e43f61ae |
|
MD5 | b626271848ea5913bcd739214e2a94cb |
|
BLAKE2b-256 | 825bb68907397ad30cb1d5e709b665bc2926cb097e225d84386baa9b1e68d16c |
File details
Details for the file aql-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: aql-0.4.1-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.24.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7fec7b2b64106edb62001c654d07eaf99821bb26e68fe757e47801a467847d3 |
|
MD5 | 6c313234890fe1decd4a59932b09352b |
|
BLAKE2b-256 | b847ac2292852750cbcebba65b0379f174937f6fd008c317fe79e7ddf9e591e7 |