Aug-15-2020, 10:01 AM
I'm trying to add data to a table in SQLite3 using the following code:
I get this error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import sqlite3 # imports the SQLite library from tkinter import * # imports tkinter library with sqlite3.connect( "TestScores.db" ) as db: # creates TestScores database cursor = db.cursor() cursor.execute( """CREATE TABLE IF NOT EXISTS Scores(Name text PRIMARY KEY, Grade text NOT NULL);""" ) # creates the Scores table with Name and Grade as fields def Add(): Name = textbox1.get() # gets Name from textbox1 Grade = textbox2.get() # gets Grade from textbox2 cursor.execute( """INSERT INTO Scores(Name, Grade) VALUES("?","?")""" , [Name],[Grade]) # adds this entry into the table db.commit() # this line saves the changes |
Error:Traceback (most recent call last):
File "C:\Users\djwil\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "c:/Users/djwil/Documents/python/learning python/Chapter 18 - SQLite/Ch18-c7.py", line 14, in Add
cursor.execute("""INSERT INTO Scores(Name, Grade)
TypeError: function takes at most 2 arguments (3 given)
I'm not sure why I get this error as I only have 2 arguments being entered in a tkinter window.