I'd like to bulk insert a list of strings into a MySQL Database with SQLAlchemy Core.
engine = create_engine("mysql+mysqlconnector://...")
meta = MetaData()
meta.bind = engine
My table layout looks like this - together with two currently unused columns (irrelevant1/2):
MyTabe = Table('MyTable', meta,
Column('id', Integer, primary_key=True),
Column('color', Text),
Column('irrelevant1', Text)
Column('irrelevant2', Text))
Unfortunately the following does not work - it inserts an empty row. What's the right way to do this?
MyTable.insert().execute(['blue', 'red', 'green'])
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…