sqlalchemy连接 MySQL(转)
from sqlalchemy import create_engine,Table,Column,Integer,String,MetaData,ForeignKey engine=create_engine("mysql+pymysql://root::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()
相关推荐
Andrea0 2020-09-18
Lzs 2020-10-23
聚合室 2020-11-16
零 2020-09-18
Justhavefun 2020-10-22
jacktangj 2020-10-14
ChaITSimpleLove 2020-10-06
周游列国之仕子 2020-09-15
afanti 2020-09-16
88234852 2020-09-15
YClimb 2020-09-15
风雨断肠人 2020-09-04
卖口粥湛蓝的天空 2020-09-15
stulen 2020-09-15
pythonxuexi 2020-09-06
abfdada 2020-08-26
梦的天空 2020-08-25