I can successfully create table in sqlite3 database using Python but I can't insert data to it
# coding: utf-8
import sqlite3
text = "Welcome"
def cur_execute(data):
con = sqlite3.connect('sqlite3.db')
try:
with con:
cur = con.cursor()
cur.execute(data)
con.commit()
except Exception as why:
print(why)
finally:
if con: con.close()
cur_execute("CREATE TABLE Hello(test TEXT)")
cur_execute("INSERT INTO Hello VALUES(?)", (text))
show to me this error : cur_execute() takes exactly 1 argument (2 given)
thx.
withfor the connection. You do not need to call close.