Python Forum
How to use place holders in tkinter sqlite
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use place holders in tkinter sqlite
#1
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.


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()
Reply


Messages In This Thread
How to use place holders in tkinter sqlite - by scratchmyhead - May-12-2020, 04:58 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Place QT Window in the middle AlphaInc 10 2,243 Aug-03-2023, 05:40 PM
Last Post: Axel_Erfurt
  Label.Place did not work? ATARI_LIVE 15 5,308 Sep-18-2020, 04:22 PM
Last Post: ATARI_LIVE
  [Tkinter] How to place scroll bar correctly scratchmyhead 1 3,961 May-18-2020, 04:17 PM
Last Post: scratchmyhead
  Python Tkinter (sqlite) scratchmyhead 1 1,695 Apr-30-2020, 09:00 PM
Last Post: menator01
  thinker button gui place next to each other jacklee26 9 4,785 Jul-04-2019, 07:48 AM
Last Post: wuf

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020