First you ought to look into using MVC methodology as your current means of handling your database connectivity is fraught with issues.
Next to handle your SQL simply do it this way then you can check your values before you use them and you can be sure that what you are doing is being done correctly by checking your SQL before you use it.
First this is the Syntax of your style of insert:
Next to handle your SQL simply do it this way then you can check your values before you use them and you can be sure that what you are doing is being done correctly by checking your SQL before you use it.
First this is the Syntax of your style of insert:
INSERT INTO table_name VALUES (value1, value2, value3, ...)
def submit(): Val1 = l1.get() Val2 = l2.get() Val3 = l3.get() Val4 = l4.get() # Debug purposes only print print('Values :',Val1, Val2, Val3, Val4) strSQL = '' strSQL += 'INSERT INTO Expense_Data.db ' strSQL += 'VALUES (' + Val1 strSQL += ', ' + Val2 strSQL += ', ' + Val3 strSQL += ', ' + Val4 strSQL += ')' # Debug purposes only print print('SQL :',strSQL) try: c.execute(strSQL) c.commit() except: print('Insert Error Occurred')So as can be seen with this you can easily add another Value to the insert if you wanted and the Insert is actually generic enough that you would design it to be fully generic and pass in the Values to insert and the Table to insert them into thus reducing your code base as well but this would only be really effective if you used the MVC methodology in its totality