python学习教程(九)sqlalchemy框架的modern映射
首先写一个modern.py文件,
from sqlalchemy.orm.session import sessionmakerfrom modern import engine,User,AdvancedUser,Teacheruser = User()user.name = 'username'user.gender = 'male'au = AdvancedUser()au.name = 'auname'au.gender = 'female'teacher = Teacher()teacher.name = 'wangdi'teacher.gender = 'female'teacher.phone = '15264397652'Session = sessionmaker()Session.configure(bind=engine)session = Session()session.add(user)session.add(au)session.add(teacher)session.flush()session.commit()