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?

Tweets:
Dennis Monsewicz @dennismonsewicz
@jasonamyers #PonyORM looks super nice. I like it better than SQLAlchemy
Matt Chisholm @glyphobet
Wow, @sqlalchemy should steal some ideas from @ponyorm!
steve mcc @daikaiju
This PonyORM talk is blowing my mind. Some very clever stuff! #ep14
Ulrich Petri @ulope
Really ingenious how PonyORM translates generator expressions to SQL. Also used a lot less magic than I expected. #europython #ep14
Links: