我在我的程序中使用了这段代码:
def insert(self, table, params):
keys = ', '.join(params.keys())
values = params.values()
query = f"INSERT INTO songs ({keys}) VALUES (?, ?);"
print(keys)
print(query)
print(values)
self.cur.execute(query , values)
self.conn.commit()
return self.cur.lastrowid
Run Code Online (Sandbox Code Playgroud)
哪个打印
name, filehash
INSERT INTO songs (name, filehash) VALUES (?, ?);
dict_values(['testaudio8.mp3',
'BA614A989B7BCF44E38D00EEFFE96F2D8BD6677D'])
Run Code Online (Sandbox Code Playgroud)
但返回错误:
self.cur.execute(query , values)
ValueError: parameters are of unsupported type
Run Code Online (Sandbox Code Playgroud)
我想将 dict_values 中的值插入问号中,但出现错误。有人可以帮忙吗?