Taiwo
Taiwo

Reputation: 15

UPDATE statement syntax error caused by a field

I'm currently using python and pypyodbc in conjunction with Microsoft access to create and use a database, and i've stumbled across this error and i cannot figure it out

cursor.execute('''UPDATE user_table
                            SET weapon1_id = ?,
                            weapon2_id = ?,
                            aid1_id = ?,
                            aid2_id = ?,
                            armour_id = ?,
                            misc1_id = ?,
                            misc2_id = ?,
                            achievements = ?,
                            user_level = ?,
                            game_level = ?,
                            xp = ?,
                            money = ? 
                            WHERE ID = ?''',
                            [current_user.inventory['weapons'][0].id,
                            current_user.inventory['weapons'][1].id,
                            1,1,1,1,1,
                            current_user.ach,
                            current_user.level,
                            current_user.game_level,
                            current_user.xp,
                            current_user.money,
                            user_id])

This is my UPDATE statement for my program, anytime it reaches this point in the code, it gives me this error

raise ProgrammingError(state,err_text)
pypyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Microsoft 
Access Driver] Syntax error in UPDATE statement.')

after messing around with it, i found out it was caused by the "current_user.money" value, so anytime i remove that value along with "money =?" the code runs fine, but i don't know why this is happening, i did create the money field in my table after creating the connection string, could that be the problem? the field is also a number and so is "current_user.money" so i don't think it would be a type mismatch, any help would be greatly appreciated

Upvotes: 0

Views: 227

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269753

My best guess is that money is a reserved word. Try using:

. . .
[money] = ?

Upvotes: 1

Related Questions