pony is a free, open source databases project written in Python and released under Apache-2.0. It has 3,818 GitHub stars, 255 forks and 358 open issues, and was last pushed 1 months ago. On this registry it ranks #168 of 203 tracked projects in Databases, with 5 head-to-head comparisons available.

What is pony?

Pony is an Apache-2.0 licensed Python object-relational mapper that maps Python classes to relational tables and translates generator-expression and lambda queries into SQL for SQLite, MySQL, PostgreSQL and Oracle.

What it is

Pony is an advanced object-relational mapper (ORM) for Python, published as the pony package and released under the Apache 2.0 license. It lives in this registry under Infrastructure & Operations / Databases, with topics covering orm, python, python3, sqlite, mysql, postgresql, oracle, cockroach and cockroachdb. Its defining feature is that queries are written as ordinary Python generator expressions and lambdas: Pony analyses the abstract syntax tree of the expression and translates it into a SQL query using a specific database dialect. Pony works with SQLite, MySQL, PostgreSQL and Oracle databases, and the topic list additionally tags CockroachDB.

The concrete problem it solves is the friction between Python business logic and database access. Instead of concatenating SQL strings or assembling query-builder chains, a developer writes select(p for p in Product if p.name.startswith('A') and p.cost <= 1000) and lets the mapper emit the dialect-specific SQL. Pony supports this with compact entity definitions, a concise query language, and the ability to work with Pony interactively inside a Python interpreter. It also reports comprehensive error messages that show the exact part of the query where an error occurred, and it can display the generated SQL in readable, indented form, so a developer can verify what will actually run against the database. The stated goal is to let developers focus on business logic instead of struggling with a mapper to retrieve data.

Key capabilities

  • Queries expressed as Python generator expressions and lambdas, analysed at the abstract syntax tree level and translated into SQL.
  • Dialect-specific SQL generation covering SQLite, MySQL, PostgreSQL and Oracle, with cockroach and cockroachdb also present in the topic list.
  • Compact entity definitions for declaring the mapping between Python classes and relational tables.
  • Interactive use directly in a Python interpreter session.
  • Comprehensive error messages that point to the exact part of the query where the error occurred.
  • Display of the generated SQL in readable, indented form.
  • An online Entity-Relationship Diagram Editor at https://editor.ponyorm.com, where a database diagram can be created, a schema generated from it, and declarative queries run in seconds.
  • A worked example application at pony/orm/examples/estore.py in the repository.

Who uses it and how

  • Python application developers who want compact entity definitions and Pythonic queries rather than string SQL, with the mapper handling dialect differences across SQLite, MySQL, PostgreSQL and Oracle.
  • Teams that prototype a schema in the online ER Diagram Editor, generate the database schema from the diagram, and immediately begin querying it with declarative queries.
  • Developers working interactively in a Python interpreter, using the indentation-formatted generated SQL and the precise error messages to debug a query.
  • Contributors and technical writers: documentation lives at https://docs.ponyorm.org with sources in the separate pony-doc repository, and development uses requirements-dev.txt plus ruff for linting and formatting.
  • Community members seeking help through the ponyorm tag on Stack Overflow, the project Telegram group, or the newsletter at ponyorm.org.

Getting started

The README documents development setup through python -m pip install -r requirements-dev.txt, followed by python -m ruff check --fix . and python -m ruff format .; the package itself is distributed as pony, as indicated by the PyPI download badge, with documentation at https://docs.ponyorm.org and the hosted ER diagram editor at https://editor.ponyorm.com.

How it compares

The facts provided name no paid or proprietary products that Pony replaces, and they name no competing Python ORM. On the evidence available here, Pony stands alone in this registry, so no contrast on license, self-hosting, data ownership or cost model can be drawn from the provided material.

When to use it — and when not to

Anyone adopting Pony must already operate one of the supported databases, whether a SQLite file or a MySQL, PostgreSQL or Oracle server, because Pony is a library rather than a hosted service. Teams that want a managed data platform, or that cannot maintain a database themselves, should look elsewhere. The honest caveats are that the repository carries 358 open issues, the README excerpt is short and points outward for most guidance, and the documentation is maintained in a separate repository rather than alongside the code.

project readme (upstream, from github) — read inline

Downloads

Downloads Downloads Downloads

Pony Object-Relational Mapper

Pony is an advanced object-relational mapper. The most interesting feature of Pony is its ability to write queries to the database using Python generator expressions and lambdas. Pony analyzes the abstract syntax tree of the expression and translates it into a SQL query.

Here is an example query in Pony:

select(p for p in Product if p.name.startswith('A') and p.cost <= 1000)

Pony translates queries to SQL using a specific database dialect. Currently Pony works with SQLite, MySQL, PostgreSQL and Oracle databases.

By providing a Pythonic API, Pony facilitates fast app development. Pony is an easy-to-learn and easy-to-use library. It makes your work more productive and helps to save resources. Pony achieves this ease of use through the following:

  • Compact entity definitions
  • The concise query language
  • Ability to work with Pony interactively in a Python interpreter
  • Comprehensive error messages, showing the exact part where an error occurred in the query
  • Displaying of the generated SQL in a readable format with indentation

All this helps the developer to focus on implementing the business logic of an application, instead of struggling with a mapper trying to understand how to get the data from the database.

See the example here

Support Pony ORM Development

Pony ORM is Apache 2.0 licensed open source project. If you would like to support Pony ORM development, please consider:

Become a backer or sponsor

Online tool for database design

Pony ORM also has the Entity-Relationship Diagram Editor which is a great tool for prototyping. You can create your database diagram online at https://editor.ponyorm.com, generate the database schema based on the diagram and start working with the database using declarative queries in seconds.

Documentation

Documentation is available at https://docs.ponyorm.org The documentation source is available at https://github.com/ponyorm/pony-doc. Please create new documentation related issues here or make a pull request with your improvements.

Development

Install the development tools:

python -m pip install -r requirements-dev.txt

Format the Python code and apply safe lint fixes:

python -m ruff check --fix .
python -m ruff format .

Check the code without changing any files:

python -m ruff check .
python -m ruff format --check .

License

Pony ORM is released under the Apache 2.0 license.

PonyORM community

Please post your questions on Stack Overflow. Meet the PonyORM team, chat with the community members, and get your questions answered on our community Telegram group. Join our newsletter at ponyorm.org. Reach us on Twitter.

Copyright (c) 2013-2026 Pony ORM. All rights reserved. info (at) ponyorm.org

Frequently asked questions

Is pony free to use?

pony is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does pony do?

Pony Object Relational Mapper

What is pony written in?

pony is primarily written in Python. Its source is publicly available at https://github.com/ponyorm/pony, and it has 3,818 GitHub stars.