user2175282
user2175282

Reputation: 81

Can't get my SQL to display my score in my database form my pygame

I have tried to create a piece of code so when my game is over or the play wins he score is displayed in the database.

Game Code:

 def gameover():
    message = Msg("Game Over")
    message.update()
    player.kill()
    shot.kill()
        SQL = 'INSERT INTO TblScore(Score) VALUES (' + str(score.value)
        Databaseconnector.INSERT(SQL)

Database Connection Code:

def INSERT(SQL):
    print(SQL)
    cursor.execute(SQL)
    conn.commit()

Error:

ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. (-3502) (SQLExecDirectW)')

Upvotes: 0

Views: 568

Answers (1)

Marc B
Marc B

Reputation: 360702

You forgot the closing bracket:

    SQL = 'INSERT INTO TblScore(Score) VALUES (' + str(score.value) + ')'
                                                                   ^^^^^^^

Upvotes: 5

Related Questions