python sqlalchemy insert multiple lines in a tuple data structure

拥有回忆 提交于 2019-12-01 11:50:23

Well I did the following:

column_names = tuple(c.name for c in hockey.c)

>>>column_names
('team', 'jersey_colour', 'stadium', 'goals', 'date', 'assists')

final = [dict(zip(column_names,x)) for x in data]

The above creates a list of dictionaries for each or the rows. This should work but when I run I get the following error:

>>>conn.execute(ins, final)

SQLite Date type only accepts Python date objects as input.

In any case this is another problem that I need to look into. That said, I am answering and accepting this question because the above dictionary should work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!