What is the correct way to insert data into a single column in a table using a python variable?
I have tried
crsr.execute("INSERT INTO PBI(Acceptance_Criteria) VALUES (?)",wi_criteria)
connection.commit()
Gives Incorrect bindings error
crsr.execute(f"INSERT INTO PBI(Acceptance_Criteria) VALUES {wi_criteria})
connection.commit()
Gives Incomplete input
What is the correct format please? Thanks.
asked Dec 3, 2021 at 6:50
Abhishek Rai
2,2474 gold badges26 silver badges49 bronze badges
1 Answer 1
You should be passing a tuple as the second parameter to cursor.execute():
crsr.execute("INSERT INTO PBI (Acceptance_Criteria) VALUES (?)", (wi_criteria,))
connection.commit()
answered Dec 3, 2021 at 6:52
Tim Biegeleisen
526k32 gold badges324 silver badges399 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Abhishek Rai
I think I tried that. Let me check. Aah..I didn't place the comma after
wi_criteriadefault