Hi all,
I have been trying to write and retrieve data from SQLite Database. So far I can make connection, cursor; but cannot get table populated(fails to execute SQL statement). Since I read somewhere that it is recommended to use ? instead of % then I tries it but I run errors. Below is the code and traceback error
Thanks alot,
def onNewTable(self, cursor, t_name):
t_date = "Date of Transaction"
t_explanations = "Transaction Explanations"
t_deposit = "Deposit Equivalent"
t_withdraw = "Withdraw Equivalent"
t_balance = "Balance After Transaction"
cursor.execute("CREATE TABLE ? (? CHAR, ? CHAR, ? CHAR, ? CHAR, ? CHAR)" (t_name, t_date, t_explanations, t_deposit, t_withdraw, t_balance) )
cursor.commit()
File "I:\Documents\Projects\Coding\Financial Management\MainApp_tabbed.py", line 201, in onNewFile
self.onNewTable(cur, "steve_test")
File "I:\Documents\Projects\Coding\Financial Management\MainApp_tabbed.py", line 215, in onNewTable
cursor.execute("CREATE TABLE ? (? CHAR, ? CHAR, ? CHAR, ? CHAR, ? CHAR)" (t_name, t_date, t_explanations, t_deposit, t_withdraw, t_balance) )
TypeError: 'str' object is not callable