问题
I have list and I want to enter each element of that list into associated indexed cells of a column in MYSQL using Python.
E.g
lst = [11,22,33,44,55,66]
MYSql column:
Data
11
22
33
44
55
66.
How can I achieve this.
回答1:
Following code will do the work:
values = [list([item]) for item in lst]
cursor.executemany(u'INSERT INTO `tbl`(`Data`)(%s)', values)
来源:https://stackoverflow.com/questions/16225128/insert-a-python-list-into-a-column-in-mysql