sqlite3.OperationalError because Python thinks my table name is a column

1 week ago 12
ARTICLE AD BOX

I am trying to access the table in my game which is called tbl[savename]. But it thinks my table name is a column.

My code is:

def save_data(self, data): conn = sqlite3.connect("dbInfo.db") identify = 0 cur = conn.cursor() print(data["username"]) cur.execute(f"""UPDATE {data["username"]} SET username = {data["username"]}, shopname = {data["shopname"]}, day = {data["day"]}, money = {data["money"]}, cash_flow = {data["cash_flow"]}, character = {data["character"]} WHERE id = ?""") conn.commit() print("Saved data!") conn.close()

But I get the error:

Exception in Tkinter callback Traceback (most recent call last): File "C:\Program Files\Python310\lib\tkinter\__init__.py", line 1921, in __call__ return self.func(*args) File "U:\Year 12 CS\CompSciProject\CompSciProject\CompSciProject\code\Startup.py", line 130, in apply_settings self.SaveAndClose() File "U:\Year 12 CS\CompSciProject\CompSciProject\CompSciProject\code\Startup.py", line 150, in SaveAndClose self.backend.save_data(data = self.player_info) File "U:\Year 12 CS\CompSciProject\CompSciProject\CompSciProject\code\Startup_backend.py", line 56, in save_data cur.execute(f"""UPDATE {data["username"]} sqlite3.OperationalError: no such column: tblGeorge
Read Entire Article