我想知道是否可以使用变量表名来更新表。这是我到目前为止所尝试的:
代码:
self.cur.execute("UPDATE (?) SET Balance = (?) WHERE ID = (?)", [table_name, newbal, self.ID])
我的代码产生以下错误:
sqlite3.OperationalError: no such column: Balance
我的桌子:
CREATE TABLE StaffTable (
ID STRING REFERENCES Accounts (ID) ON DELETE CASCADE
PRIMARY KEY,
First_name TEXT,
Last_name TEXT,
Balance STRING,
Allowance STRING
);
CREATE TABLE StudentTable (
ID STRING PRIMARY KEY
REFERENCES Accounts (ID) ON DELETE CASCADE,
First_name TEXT,
Last_name TEXT,
Balance STRING
);