到目前为止这是我的文件:
from sqlalchemy import create_engine,ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship,backref
from sqlalchemy import Column,Integer,String
from sqlalchemy import Table,Text
engine = create_engine('MysqL://root:ababab@localhost/alctest',echo=False)
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer,primary_key = True)
name = Column(String(100))
fullname = Column(String(100))
password = Column(String(100))
addresses = relationship("Address",order_by="Address.id",backref="user")
def __init__(self,name,fullname,password):
self.name = name
self.fullname = fullname
self.password = password
def __repr__(self):
return "Metadata.create_all(engine)
最佳答案