Mapping entities to database tables

Now we need to create database tables where we will persist our data. For this purpose, we need to call the generate_mapping() method on the Database object:

  1. >>> db.generate_mapping(create_tables=True)

The parameter create_tables=True indicates that, if the tables do not already exist, then they will be created using the CREATE TABLE command.

All entities connected to the database must be defined before calling generate_mapping() method.