Use Pure Python
to Speak to Your Data
  • Translates Python generators to SQL
  • Graphical editor for models
  • Identity Map, optimistic transactions
    and more...

What is Pony ORM?

Pony is a cool and new Python ORM that lets you query a database using Python generators. These generators are then translated into effective SQL.

Screencast

Screencast

Try Pony now!

You can install it from PyPi:

pip install pony

Or get Pony sources from GitHub.

Declarative queries

Pony allows you to interact with databases in pure Python in the form of generator expressions, which are then translated into SQL. Python generator:
select(c for c in Customer
         if sum(c.orders.price) > 1000)
is translated to the following SQL:
SELECT "c"."id"
FROM "Customer" "c"
  LEFT JOIN "Order" "order-1"
    ON "c"."id" = "order-1"."customer"
GROUP BY "c"."id"
HAVING coalesce(SUM("order-1"."total_price"), 0) > 1000
              

Diagram editor

You can use the graphical ER diagram editor which generates Python code for models Diagram

What others say about Pony ORM?