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.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
#2
Quote: I'm getting the following error: TypeError
Please Post entire unmodified error traceback (in bbcode error tags)
It contains information that is most helpful in finding cause or error.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using place for a button, many examples but AttributeError, tkinter Edward_ 3 982 Dec-17-2024, 09:06 PM
Last Post: deanhystad
  Place QT Window in the middle AlphaInc 10 6,280 Aug-03-2023, 05:40 PM
Last Post: Axel_Erfurt
  Label.Place did not work? ATARI_LIVE 15 7,912 Sep-18-2020, 04:22 PM
Last Post: ATARI_LIVE
  [Tkinter] How to place scroll bar correctly scratchmyhead 1 4,787 May-18-2020, 04:17 PM
Last Post: scratchmyhead
  Python Tkinter (sqlite) scratchmyhead 1 2,321 Apr-30-2020, 09:00 PM
Last Post: menator01
  thinker button gui place next to each other jacklee26 9 7,164 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