开发者

MySQL insert single variable with python

开发者 https://www.devze.com 2023-02-14 07:12 出处:网络
Im having problem with single value inserts. Using pyodbc LL= [] .... sqla = \'INSERT INTO d.table VALUES (?,?,?,?,?,?,?)\'

Im having problem with single value inserts. Using pyodbc

LL= []
....
sqla = 'INSERT INTO d.table VALUES (?,?,?,?,?,?,?)'
csr.executemany(sqla, LL)

Works开发者_运维知识库, if LL is single column of data as a list...does not work.

LL= []
....
sqla = 'INSERT INTO d.table VALUES (?)'
csr.execute(sqla, LL)

How do I fix?

Then

LL= []
....
sqla = 'INSERT INTO d.table VALUES (?)'
csr.execute(sqla, LL)

If LL is Id only, The database table has cols of ID, AAA,BBB, CCC, How do I insert....

LL= [['TDW'], ['TD0'], ['TD0'], ['TDW'], ['TD10'] ]


sqla = 'INSERT INTO d.table (column_name) VALUES (?)'

This is right syntax of INSERT QUERY.

0

精彩评论

暂无评论...
验证码 换一张
取 消