May-12-2020, 04:58 AM
(This post was last modified: May-12-2020, 05:09 AM by scratchmyhead.)
I have a program with a sqlite database and I'm trying to update a record by using place holders. I'm not sure why but I'm getting the following error: TypeError: function takes at most 2 arguments (3 given) So here is a sample of my code if anyone can figure out what I'm doing wrong.
I found out the correct code to use. The correct way is the following:
conn = sqlite3.connect('roominventory.db')
c = conn.cursor()
c.execute("SELECT * FROM rooms")
records = c.fetchall()
for record in records:
if record[0] == roomget:
break
t = ("N",)
rm = (roomget,)
c.execute("UPDATE rooms SET vacant = ? WHERE number = ?", t, rm)
c.fetchall()
conn.commit()
conn.close()I found out the correct code to use. The correct way is the following:
conn = sqlite3.connect('roominventory.db')
c = conn.cursor()
c.execute("SELECT * FROM rooms")
records = c.fetchall()
for record in records:
if record[0] == roomget:
break
t = "N"
rm = roomget
c.execute("UPDATE rooms SET vacant = ? WHERE number = ?", (t, rm))
c.fetchall()
conn.commit()
conn.close()
