Pony ORM Documentation

repository·main·Indexed 26 days ago

https://github.com/ponyorm/pony

An advanced Python Object-Relational Mapper (ORM) that translates Python generator expressions and lambdas into optimized SQL. Supports SQLite, MySQL, PostgreSQL, and Oracle databases, and includes an online Entity-Relationship Diagram Editor for database design and schema generation.

Tokens
276
Snippets
1
Records
4
Agent score
37%

What's inside Pony ORM

  1. Overview of Pony Object-Relational Mapper

    main

    Pony is an advanced object-relational mapper (ORM) that allows you to write database queries using Python generator expressions and lambdas. Pony analyzes the abstract syntax tree (AST) of these expressions and translates them into optimized SQL queries for specific database dialects.

    Supported databases include:

    • SQLite
    • MySQL
    • PostgreSQL
    • Oracle
  2. Use the Entity-Relationship Diagram Editor for database design

    main
    You can use the online Entity-Relationship Diagram Editor to prototype your database. The tool allows you to create a database diagram online, generate a database schema based on that diagram, and begin working with declarative queries immediately.
  3. Querying with Python generator expressions

    main

    Instead of writing raw SQL, you can use Pythonic generator expressions to query your database. Pony translates these expressions into the appropriate SQL dialect.

    Example query:

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