PyGraphile
A Python library inspired by PostGraphile — automatically generates GraphQL APIs from your database schema.
Point PyGraphile at a SQLite file or a MariaDB/MySQL database, and get a fully working, ASGI-compatible GraphQL API. No schema writing, no manual resolvers.
🚧 Project Status
v0.6.2 — Early access. Core query API is working for SQLite, MariaDB, and MySQL. Mutations, filtering, and PostgreSQL are on the roadmap.
✨ Features
- 🔍 Schema introspection — Automatically reads tables, columns, and types from your database
- ⚡ Instant GraphQL — Generates a complete, executable GraphQL schema with resolvers on the fly
- 🗄️ Multi-database support — SQLite, MariaDB, and MySQL supported today
- 🔤 Identifier sanitization — Table and column names with spaces or special characters are automatically converted to valid GraphQL names (e.g.
"full name"→full_name,"tabapi request log"→TabapiRequestLog) - 🔌 ASGI native — Returns a standard ASGI app you can mount into FastAPI, Starlette, or any ASGI framework
- 🐍 Pure Python — Supports Python 3.9 through 3.13+
🚀 Installation
SQLite (no extra dependencies)
pip install pygraphile
MariaDB / MySQL
pip install "pygraphile[mariadb]"
# or for mysql alias:
pip install "pygraphile[mysql]"
Using uv
uv add pygraphile # SQLite only
uv add "pygraphile[mariadb]" # with MariaDB/MySQL support
From source
git clone https://github.com/dshaw0004/pygraphile.git
cd pygraphile
uv pip install -e .
📖 Quick Start
SQLite
from pygraphile import PyGraphile
from fastapi import FastAPI
import uvicorn
app = FastAPI()
pg = PyGraphile('mydb.sqlite', db_type='sqlite', debug=True)
app.mount('/graphql', pg.get_query_app())
if __name__ == '__main__':
uvicorn.run(app, port=8000)
MariaDB / MySQL
from pygraphile import PyGraphile
from fastapi import FastAPI
import uvicorn
app = FastAPI()
md = PyGraphile(
'mariadb://user:password@127.0.0.1:3306/mydb',
db_type='mariadb', # or 'mysql'
debug=True,
)
app.mount('/graphql', md.get_query_app())
if __name__ == '__main__':
uvicorn.run(app, port=8000)
What gets generated
Given a table named "tabapi request log" with columns id INT and full name VARCHAR:
# Table and column names with spaces are sanitized automatically
type TabapiRequestLog {
id: Int
full_name: String
}
type Query {
tabapi_request_log: [TabapiRequestLog]
}
Query it:
curl -X POST http://localhost:8000/graphql/ \
-H "Content-Type: application/json" \
-d '{"query":"{ tabapi_request_log { id full_name } }"}'
With debug=True, an Apollo GraphQL Explorer is also available at /graphql.
⚙️ API Reference
PyGraphile(db_name, db_type, migration_folder, debug)
| Parameter | Type | Default | Description |
|---|---|---|---|
db_name |
str |
'pygraphile.sqlite' |
SQLite file path, or MariaDB/MySQL connection URI |
db_type |
str |
'sqlite' |
'sqlite', 'sqlite3', 'mariadb', or 'mysql' |
migration_folder |
str |
'nomigration' |
Reserved for future migration support |
debug |
bool |
False |
Enables Apollo Explorer and verbose logging |
pg.get_query_app()
Returns an ASGI-compatible Ariadne GraphQL app ready to be mounted.
Utility functions
from pygraphile import sanitize_field_name, sanitize_type_name
sanitize_field_name("full name") # → "full_name"
sanitize_field_name("tabapi request log") # → "tabapi_request_log"
sanitize_type_name("tabapi request log") # → "TabapiRequestLog"
sanitize_type_name("order-items") # → "OrderItems"
🗺️ Roadmap
- Project setup and structure
- SQLite schema introspection and query resolvers
- GraphQL schema generation
- MariaDB & MySQL support
- Identifier sanitization (spaces & special characters in table/column names)
- Mutation support (INSERT / UPDATE / DELETE)
- PostgreSQL support
- Filtering & pagination
- Authentication & authorization
- Plugin system
🤝 Contributing
Contributions are welcome! This project is in early stages, so there's plenty of opportunity to shape its direction.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License — see the LICENSE file for details.
🙏 Acknowledgments
- Inspired by PostGraphile — An amazing tool for PostgreSQL
- Built with Ariadne for GraphQL execution
- Tooling powered by uv
📬 Contact
- GitHub: @dshaw0004
- Project: https://github.com/dshaw0004/pygraphile
Note: This project is under active development. APIs and features are subject to change.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygraphile-0.6.2.tar.gz.
File metadata
- Download URL: pygraphile-0.6.2.tar.gz
- Upload date:
- Size: 143.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ea75dab5f1f130de0e17dbbd0885766373378addb8cf0ebd720ff5bc72bdeef
|
|
| MD5 |
400f2c1b5ce5dba78c423c2e32ace27d
|
|
| BLAKE2b-256 |
d4acc6118eac32280b5fb808cb83d2c861ffbd9ff9528d6cd3e86498e6f4521d
|
Provenance
The following attestation bundles were made for pygraphile-0.6.2.tar.gz:
Publisher:
workflow.yml on dshaw0004/pygraphile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygraphile-0.6.2.tar.gz -
Subject digest:
1ea75dab5f1f130de0e17dbbd0885766373378addb8cf0ebd720ff5bc72bdeef - Sigstore transparency entry: 2859488792
- Sigstore integration time:
-
Permalink:
dshaw0004/pygraphile@cd3a5c56f7714e8093c9478f52f6181071bd70fb -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/dshaw0004
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@cd3a5c56f7714e8093c9478f52f6181071bd70fb -
Trigger Event:
release
-
Statement type:
File details
Details for the file pygraphile-0.6.2-py3-none-any.whl.
File metadata
- Download URL: pygraphile-0.6.2-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
486f24c4501a3529d792c43e781609b753cd410b1a1721eaad1d22fa5638ff25
|
|
| MD5 |
b833b9405120ab7654fb0fba3f08a9db
|
|
| BLAKE2b-256 |
29aa0ab5031cb82564cc982d26270a3623e8cc80d0a860ab8a005b962534586f
|
Provenance
The following attestation bundles were made for pygraphile-0.6.2-py3-none-any.whl:
Publisher:
workflow.yml on dshaw0004/pygraphile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygraphile-0.6.2-py3-none-any.whl -
Subject digest:
486f24c4501a3529d792c43e781609b753cd410b1a1721eaad1d22fa5638ff25 - Sigstore transparency entry: 2859488893
- Sigstore integration time:
-
Permalink:
dshaw0004/pygraphile@cd3a5c56f7714e8093c9478f52f6181071bd70fb -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/dshaw0004
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@cd3a5c56f7714e8093c9478f52f6181071bd70fb -
Trigger Event:
release
-
Statement type: