День добрый,
подскажите где я ошибся и что не так с моим запросом?
cursor.execute("INSERT INTO table_name (abcd) VALUES(?)", (data))
#!/usr/bin/env python3
import sqlite3
def insert(conn, data):
cursor=conn.cursor()
cursor.execute("INSERT INTO table_name (abcd) VALUES(?)", (data))
conn.commit()
def main():
data = 'input data'
conn = sqlite3.connect("./test.db")
cursor = conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS table_name (abcd TEXT)")
insert(conn, data)
conn.commit()
conn.close()
if __name__ == "__main__":
main()
ошибка:
Traceback (most recent call last):
File "./test.py", line 27, in
main()
File "./test.py", line 21, in main
insert(conn, data)
File "./test.py", line 6, in insert
cursor.execute("INSERT INTO table_name (abcd) VALUES(?)", (data))
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 10 supplied.