Alchemy QL
Lightweight GraphQL engine powered by SQLAlchemy
🚀 Key Features
Alchemy QL's key features include:
- Read Only - Provides read-only graphql interface into your database
- Data Type Support - Currently supported data types:
- Built in types: int, float, bool, str, bytes
- Date types: date, datetime, time
- Enums
- JSON fields
- Relationships
- Query Options - Currently supported query options:
- Filtering
- Ordering
- Pagination (using offset & limit)
- Sync & Async support
- Fragment Query support
- Optimised SQL Queries
- ORM Support - Currently supported sqlalchemy orm:
- Declarative base with mapping
- Classic declarative base
ℹ️ Installation
# Using pip
pip install alchemyql
# Using poetry
poetry add alchemyql
# Using uv
uv add alchemyql
# With FastAPI Extension
uv add alchemyql[fastapi]
📦 Dependencies
- Sqlalchemy (v2)
- Graph QL Core
📘 How to use
Step 1 - Create your Alchemy QL engine (sync or async):
from alchemyql import AlchemyQLSync, AlchemyQLAsync
sync_engine = AlchemyQLSync()
async_engine = AlchemyQLAsync()
Step 2 - Register your sqlalchemy tables:
from your_db import Table
engine.register(
Table,
query_name="tables",
include_fields=["field_one", "field_two"],
filter_fields=["field_one"],
order_fields=["field_one"],
pagination=True,
max_limit=100
...
)
Step 3 - Build your schema:
engine.build_schema()
Step 4 - Run queries:
query = "query { table { field } }"
db = session_factory() # SQLAlchemy DB session
# Sync Variation
res = sync_engine.execute_query(query=query, db_session=db)
# Async Variation
res = await async_engine.execute_query(query=query, db_session=db)
📘 Supported Options
Engine Creation:
| Key | Type | Default | Description |
|---|---|---|---|
| max_query_depth | int | None | The maximum depth allowed for nested queries |
Registering Table:
| Key | Type | Default | Description |
|---|---|---|---|
| graphql_name | str | None | Customise the graphql type name (defaults to sql tablename) |
| query_name | str | None | Customise the top-level graphql query field name (defaults to graphql name + "s") |
| description | str | None | Customise the graphql type descripton |
| query | bool | True | Whether to allow direct querying of table |
| include_fields | list[str] | None | Allow only specific fields to be exposed |
| exclude_fields | list[str] | [] | Block specific fields from being exposed |
| relationships | list[str] | [] | Relationships to be exposed (target table must be registered aswell) |
| filter_fields | list[str] | [] | Allow filtering for specific fields |
| order_fields | list[str] | [] | Allow ordering for specific fields |
| default_order | dict[str, Order] | None | Default order to apply to queries |
| pagination | bool | False | Whether to support pagination |
| default_limit | int | None | Default number of records that can be returned in 1 query |
| max_limit | int | None | Maximum number of records that can be returned in 1 query |
NOTE: if you do not specify include_fields or exclude_fields it will default expose all fields.
NOTE: if you specify query=False, then all filtering & ordering & pagination is disabled. This is for the case where a table should only be available via a relationship
Filtering Options:
| Type | Supported Filters |
|---|---|
| int | eq, ne, gt, ge, lt, le, in |
| float | eq, ne, gt, ge, lt, le, in |
| bool | eq, ne |
| str | eq, ne, contains, startswith, endswith, icontains, istartswith, iendswith, in |
| date | eq, ne, gt, ge, lt, le, in |
| datetime | eq, ne, gt, ge, lt, le, in |
| time | eq, ne, gt, ge, lt, le, in |
| Enum | eq, ne, in |
All other types are not currently supported for filtering.
📘 Logging
AlchemyQL uses the "alchemyql" logger.
Other docs can be found in: docs/
Security Notes
AlchemyQL is read-only, but it can still expose sensitive data if tables, fields, or relationships are registered too broadly.
- Prefer
include_fieldsfor public APIs so new database columns are not exposed automatically. - Register only relationships that are safe for callers to traverse.
- Use
max_query_depth,pagination,default_limit, andmax_limitfor externally reachable endpoints. - Keep
filter_fieldsandorder_fieldslimited to fields that are indexed or safe to reveal. - Add authentication and authorization at the framework layer, for example with the FastAPI router
auth_dependency.
📘 Extensions
AlchemyQL has the following extensions:
- FastAPI - sync and async pre-created routers available (see Doc )
ℹ️ License
This project is licensed under the terms of the MIT license.
Metadata
Release files for alchemyql 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| alchemyql-0.0.4.tar.gz | 12.7 kB | Without provenance | Details for alchemyql-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| alchemyql-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for alchemyql-0.0.4-py3-none-any.whl |
Total release size: 29.3 kB
Release files / alchemyql-0.0.4.tar.gz
| Download URL | alchemyql-0.0.4.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea495b6880ef64de2c8f97c55128d45cbc95d1b26ee6630451075cdde555fe84
|
|
BLAKE2b-256 checksum How to use checksums |
48ff9fef020e49f7064ea595e68011130d92467e1e38be5dc476bf8ba5048daf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / alchemyql-0.0.4-py3-none-any.whl
| Download URL | alchemyql-0.0.4-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0cf39774be3114627259cd7b69ae513b27c09662afb99929027aff2627da0d8b
|
|
BLAKE2b-256 checksum How to use checksums |
4bdd6d61d76b27aa5956660070fa786371b8a4d3ee052cfac2c9e5ca1acfb151
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for alchemyql 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.