I am trying to do the code as follows to register a player with a given name, but I can't get the argument name
to do anything… I thought that %s
was the variable to insert a string into a database, but it doesn't seem to work.
import psycopg2
def registerPlayer(name):
"""Registers new player."""
db = psycopg2.connect("dbname=tournament")
c = db.cursor()
c.execute("insert into Players values (%s);")
db.commit()
db.close()
registerPlayer("Butter")
When I run it, I get the error message:
ProgrammingError: syntax error at or near "%"
LINE 1: insert into Players values (%s);