Skip to main content

Lightweight Graph QL engine powered by SQL Alchemy

Project description

Alchemy QL

Lightweight GraphQL engine powered by SQLAlchemy

CI Package version Supported Python versions


🚀 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
  • 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


📘 How to use

Step 1 - Create your Alchemy QL engine (sync or async):

from alchemyql import AlchemyQLSync, AlchemyQLAsync

sync_engine = AlchemyQLSync()
async_engine = AlchemyQLSync()

Step 2 - Register your sqlalchemy tables:

from your_db import Table

engine.register(
    Table, 
    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)
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, 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/


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

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

alchemyql-0.0.1a4.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alchemyql-0.0.1a4-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file alchemyql-0.0.1a4.tar.gz.

File metadata

  • Download URL: alchemyql-0.0.1a4.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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}

File hashes

Hashes for alchemyql-0.0.1a4.tar.gz
Algorithm Hash digest
SHA256 96bdb6e9e50e6bd380b30c157a9e4f2d637229897e0753e0892fd39d3154c6fe
MD5 2be3b167007192f2b4bc38b4fc89283e
BLAKE2b-256 982b9d45a3ef52f44321ac65b2a32722b10c438195c7348f80fac103623bc541

See more details on using hashes here.

File details

Details for the file alchemyql-0.0.1a4-py3-none-any.whl.

File metadata

  • Download URL: alchemyql-0.0.1a4-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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}

File hashes

Hashes for alchemyql-0.0.1a4-py3-none-any.whl
Algorithm Hash digest
SHA256 cb04338538c96c3258906dec9d86376bf60138fa7148ced6e2d5fbdedb6e3677
MD5 78a2ad6b915828dfebc3b60547973668
BLAKE2b-256 73bd4a556f4d5364570f5d2933e31325e3a019f44672362a1f7453e7f141556e

See more details on using hashes here.

Supported by

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