https://github.com/omnilib/aql
asyncio query generator
https://github.com/omnilib/aql
database hacktoberfest python python3 query-builder
Last synced: 9 months ago
JSON representation
asyncio query generator
- Host: GitHub
- URL: https://github.com/omnilib/aql
- Owner: omnilib
- License: mit
- Created: 2018-09-06T00:46:15.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2024-07-22T20:07:19.000Z (almost 2 years ago)
- Last Synced: 2025-09-27T05:25:53.756Z (9 months ago)
- Topics: database, hacktoberfest, python, python3, query-builder
- Language: Python
- Homepage: https://aql.omnilib.dev
- Size: 200 KB
- Stars: 59
- Watchers: 3
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Roadmap: docs/roadmap.rst
Awesome Lists containing this project
README
aql
===
Simple, async query library for modern Python
[](https://github.com/omnilib/aql/actions)
[](https://codecov.io/gh/omnilib/aql)
[](https://pypi.org/project/aql)
[](https://github.com/omnilib/aql/blob/main/LICENSE)
[](https://github.com/ambv/black)
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:
```python
@table("objects")
class Object:
id: PrimaryKey[AutoIncrement[int]]
name: Unique[str]
description: text
created: datetime
```
Build queries:
```python
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:
```python
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:
```python
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 [Amethyst Reese](https://noswap.com), 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.