0

I'm creating a memory quiz game where it asks the user about their day (using python).

I'm trying to create a progress graph using matplotlib and pandas, however, when I run the code, I get the following error:

pandas.errors.DatabaseError: Execution failed on sql '('SELECT Date, Score FROM scoring WHERE UserID =?', ('Kgarda43',))': execute() argument 1 must be str, not tuple

This is my code for the area I am getting an error:

connection=sqlite3.connect('Memory.db')
cursor=connection.cursor()
sql=("SELECT Date, Score FROM scoring WHERE UserID =?", (Username_Login.value,))
data= pandas.read_sql(sql,connection)#collecting the data

Any help would be great. Thanks!

0

1 Answer 1

1

I suspect the UserID field in your database is supposed to be a string, therefore upon finding this error:

execute() argument 1 must be str, not tuple

You can fix it by correctly using your commas inside your query:

sql= '''
SELECT Date, Score 
FROM scoring 
WHERE UserID ='?'
     '''
Sign up to request clarification or add additional context in comments.

2 Comments

I seem to be getting the same error :\
I have edited my comment. Forgot to remove brackets, therefore the query was still technically a tuple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.