pony
Pony Object-Relational Mapper
What it is and what it does
Pony is an object-relational mapper that bridges Python and relational databases by translating Python generator expressions and lambdas into SQL. Instead of writing raw SQL or using a separate query DSL, you define your database entities as Python classes and query them using Pythonic syntax—Pony analyzes the abstract syntax tree and generates the appropriate SQL for your target database (SQLite, MySQL, PostgreSQL, or Oracle).
The package emphasizes developer productivity through compact entity definitions, readable generated SQL output, and clear error messages that pinpoint problems in your query. It supports interactive use in a Python interpreter and works with modern Python versions (3.10–3.14). With zero runtime dependencies and low install friction, it's designed to let you focus on application logic rather than database plumbing.
Use it for:
- Build web applications with declarative database models and Pythonic queries instead of raw SQL.
- Prototype database schemas interactively using the Pony Entity-Relationship Diagram Editor.
- Write data access layers for multi-database applications that need to target SQLite, MySQL, PostgreSQL, or Oracle.
- Debug database queries by inspecting the readable SQL that Pony generates from your Python expressions.
- Develop applications where you want ORM functionality without heavyweight framework dependencies.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pony is an object-relational mapper that lets you write database queries using Python generator expressions and lambdas, which it translates to SQL for SQLite, MySQL, PostgreSQL, and Oracle.
Yes. Pony is actively maintained, has no runtime dependencies, carries a permissive Apache-2.0 license, and offers a genuinely Pythonic query interface that sets it apart from conventional ORMs. It's well-suited for developers who want to write database queries as Python code rather than SQL strings or builder chains. No known vulnerabilities and broad Python version support (3.10–3.14) make it a low-risk choice.
Install
pony on PyPI
pip
pip install ponyuv
uv add ponypoetry
poetry add ponyInstalling pony
Before you install
Low friction install with no runtime dependencies. Actively maintained as of 2026-08-10 with recent releases and a stable repository.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions.
Quickstart
pip install pony
from pony.orm import *
db = Database()
db.bind('sqlite', ':memory:')
class Product(db.Entity):
name = PrimaryKey(str)
cost = Required(int)
db.generate_mapping(create_tables=True)
with db_session:
select(p for p in Product if p.cost <= 1000)
Requires Python 3.10 or later (3.10–3.14 supported).
Verify before relying
- Performance characteristics compared to other ORMs for large result sets or complex joins.
- Whether the package handles database migrations or schema versioning.
- Support status and timeline for Python 3.15 and beyond.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (<3.15,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 5 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 646,516/month — #5,594 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pony-0.7.20-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
tortoise-ormTortoise ORM is an async-native…
permissive · top 15,000 on PyPI
SQLAlchemySQLAlchemy is a Python SQL toolkit and Object…
permissive · top 100 on PyPI
django-mysqlDjango-MySQL extends Django's ORM with MySQL…
permissive · top 15,000 on PyPI
peeweePeewee is a lightweight ORM that maps Python…
unclear · top 1,000 on PyPI
sqlalchemy-mixinsProvides Active Record-style mixins for…
permissive · top 15,000 on PyPI
sqlalchemy-risingwaveProvides a SQLAlchemy dialect that enables…
permissive · top 15,000 on PyPI
pypika-tortoiseGenerates SQL queries programmatically for…
permissive · top 15,000 on PyPI
mongo-query-matchProvides a MongoDB-like query language for…
unclear · top 15,000 on PyPI
djongoDjongo translates Django ORM queries into…
permissive · top 15,000 on PyPI
prismaPrisma Client Python is a type-safe ORM that…
permissive · top 5,000 on PyPI