Declaring an entity

Each entity belongs to a database. That is why before defining entities you need to create an object of the Database class:

  1. from pony.orm import *
  2. db = Database()
  3. class MyEntity(db.Entity):
  4. attr1 = Required(str)

The Pony’s Database object has the Entity attribute which is used as a base class for all the entities stored in this database. Each new entity that is defined must inherit from this Entity class.