-1

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
0

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

1 Comment

I think I tried that. Let me check. Aah..I didn't place the comma after wi_criteria

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.