HELLO fellow programmers today i present you with a bug that i have in my script the debugger tells me psycopg2.errors.SyntaxError: syntax error at or near "user" LINE 1: CREATE TABLE IF NOT EXISTS score (user VARCHAR(255),highscor... i dont understand what is wrong with my syntax , the url is removed for privacy reasons its included in the actual code the script in savescore would run whenever the player would press the button Save Score then it would send the players name and highscore to my database
urlDATABASE = "urlnot shown "
up.uses_netloc.append("postgres")
urldb = up.urlparse(urlDATABASE)
connectiondb = psycopg2.connect(database=urldb.path[1:],
user=urldb.username,
password=urldb.password,
host=urldb.hostname,
port=urldb.port)
cur = connectiondb.cursor(cursor_factory=psycopg2.extras.DictCursor)
def savescore():
global highscore
global PlayerEntry
Nume="score"#numele tabelului
create=f"CREATE TABLE IF NOT EXISTS {Nume} (user VARCHAR(255),highscore VARCHAR(255))"
cur.execute(create)#am creat tabelul
scriptadd= "INSERT INTO "+Nume+" (user,highscore) VALUES(%s,%s)"
tupple=(PlayerEntry,highscore)
cur.execute(scriptadd,tupple)#trimite informatiile la server ca sa execute scriptul
connectiondb.commit()