如何为python sqlite3 upsert函数编写正确的语法?

时间:2020-11-02 02:23:01

标签: python-3.x list sqlite dictionary upsert

我有一个字典值列表,我正在尝试使用此代码在数据库中进行更新,但我无法正确获取语法:

def update_table(database, table, stream_type, entry):
    conn = sqlite3.connect(database + '.db')
    c = conn.cursor()
    c.execute('''UPSERT INTO ''' + table + 
              ' VALUES (?,?,?,?)', entry +
              'ON CONFLICT stream_type = ' + stream_type) 

update_table(database = 'database',
             table='table', 
             stream_type = 'stream_type',
             entry = list(dictionary.values()))

我得到:

TypeError: can only concatenate list (not "str") to list

我该如何正确编写?香港专业教育学院读了十几篇文章,但没有确切的问题,我是一个初学者,谢谢您的帮助!

0 个答案:

没有答案