Asim Dinda
Asim Dinda

Reputation: 13

Query regarding python database programming

I am using the below code to delete a row from sqlite table.

def deleteFromTable(item):
    conn = sqlite3.connect("lite.db")
    cur = conn.cursor()
    cur.execute("DELETE FROM store WHERE item=?", (item,))
    conn.commit()
    conn.close()

Why do i need to use comma after item (item,) while passing the argument?

Upvotes: 0

Views: 33

Answers (1)

NobbyNobbs
NobbyNobbs

Reputation: 1434

('String') evaluates into string, but ('string',) evaluates into tuple. that's why you need comma.

Upvotes: 1

Related Questions