from sqlalchemy import create_engine,Table,Column,Integer,String,MetaData,ForeignKey engine=create_engine("mysql+pymysql://root:[email protected]:3306/test",echo=True) metadata=MetaData(engine) user=Table(‘user‘,metadata, Column(‘id‘,Integer,primary_key=True), Column(‘name‘,String(20)), Column(‘fullname‘,String(40)), ) address_table = Table(‘address‘, metadata, Column(‘id‘, Integer, primary_key=True), Column(‘user_id‘, None, ForeignKey(‘user.id‘)), Column(‘email‘, String(128), nullable=False) ) metadata.create_all()
原文地址:https://www.cnblogs.com/luoye00/p/11982179.html
时间: 2024-11-09 03:14:28