How To Use SQL Parameters
I'm trying to create a database for a simple game I'm making and having an issue with querying it for the players stats. So far the database can be searched and updated, but only b
Solution 1:
VALUES is a required part of the INSERT statement.
A parameter marker (?
) just replaces the value itself:
command = ("""
SELECT score FROM players
WHERE username = ?
""")
params = ['John Smith']
return cur.execute(command, params).fetchone()[0]
Solution 2:
example_data = [("John Smith", "Password", 10)]
cur.executemany("""
INSERT INTO players
VALUES (?, ?, ?)""",
Have you considered giving up? Too few commas
Post a Comment for "How To Use SQL Parameters"