from peewee import *
mysql_db = MySQLDatabase(
'test',
host='localhost',
port=3306,
user='root',
passwd=''
)
mysql_db.connect()
class MySQLModel(Model):
class Meta:
database = mysql_db
class Person(MySQLModel):
name = CharField()
birthday = DateField()
is_relative = BooleanField()
class Pet(MySQLModel):
owner = ForeignKeyField(Person, related_name='pets')
name = CharField()
animal_type = CharField()
if __name__ == '__main__':
# mysql_db.create_tables([Person, Pet])
pass