0
如何將行添加到我的數據庫表中,使用sqlalchemy? 我用下面的代碼:將行添加到聲明表sqlalchemy
for i in range(count):
name = Utils.uniqID()
class name(Base):
__tablename__ = name
first = Column(Integer, primary_key = True)
second = Column(String)
third = Column(String)
def __init__(self, first = None, second = None, third = None):
self.first = first
self.second = second
self.third = third
Base.metadata.create_all(engine)
我想旁邊的代碼添加行:
def insertRandomRows(engine, table, count):
rows = []
for i in range(count):
rows.append(table('af', 'adf', 'adf'))
sessionmaker(bind = engine)().add_all(rows)
enter code here
但他們並沒有出現在數據庫