Creating entity instances

Now, let’s create five objects that describe three persons and two cars, and save this information in the database:

  1. >>> p1 = Person(name='John', age=20)
  2. >>> p2 = Person(name='Mary', age=22)
  3. >>> p3 = Person(name='Bob', age=30)
  4. >>> c1 = Car(make='Toyota', model='Prius', owner=p2)
  5. >>> c2 = Car(make='Ford', model='Explorer', owner=p3)
  6. >>> commit()

Pony does not save objects in the database immediately. These objects will be saved only after the commit() function is called. If the debug mode is turned on, then during the commit(), you will see five INSERT commands sent to the database.