skillfed

pony

Pony Object-Relational Mapper

pony v0.7.20 646.5K downloads/30d#5,594 on PyPI3,820
Permissive license Apache-2.0 Active released

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 pony

uv

uv add pony

poetry

poetry add pony

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: PyPyTopic :: DatabaseTopic :: Software Development :: Libraries

Tags

python orm query generatordatabase mapper lambda expressionssql query from python codeobject relational mapperpony ormpython database abstractiondeclarative database queries
ormquery-buildersql-generation

More Libraries packages