简体   繁体   中英

sqlite3.OperationalError: near “/”: syntax error

How do i divide 2 different fields which sets a value to another field in sqllie3

cursor.execute(f"UPDATE main SET W/L Ratio = Wins/Loss WHERE Players = {int(winner_id)}")

You seem to have a name that has non-standard characters. I would recommend naming the column as something like win_loss_ratio . Then it would not need escaping.

But if you have no control over this, then you need to use double quotes (or perhaps square braces):

SET "W/L Ratio" = Wins / Loss

You are just missing your quotations

cursor.execute(f'UPDATE main set "W/L Ratio" = Wins/Loss WHERE Players = {int(winner_id)}')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM