Reputation: 1609
I am using Sqlite3 with python and creating a database with a table called tblScheduledWork. When I run my script it opens up a tkinter GUI which I fill in the form details with, then when I click submit it runs my function callback. However, for some reason it is adding an entry as soon as I run the program with just a - in the action_time column and // in the scheduled_date column, as you can see in my code the only place I use these symbols is when joining some strings together to input into two columns Action time and Scheduled date.
def callback():
c.execute('''CREATE TABLE IF NOT EXISTS tblScheduledWork
(Job_ID INTEGER PRIMARY KEY UNIQUE, Action_Time TEXT, Scheduled_Date TEXT, Ticket_Id INT, Client TEXT,
To_Do TEXT, Shift TEXT, Completed TEXT, Notes TEXT, UNIQUE (Ticket_Id))''')
entries = []
action_time = str(action.get() + ' - ' + action2.get())
scheduled_date = str(scheduled_day.get() + '/' + scheduled_month.get() + '/' + scheduled_year.get())
ticket_id = ticket.get()
client_name = client.get()
to_do = todo.get()
shift_time = shift.get()
completed_yesno = completed.get()
notes_yesno = notes.get()
entries.append((action_time, scheduled_date, ticket_id, client_name, to_do, shift_time, completed_yesno, notes_yesno))
c.executemany('''INSERT OR IGNORE INTO tblScheduledWork (Action_Time, Scheduled_Date, Ticket_Id, Client,
To_Do, Shift, Completed, Notes) VALUES
(?,?,?,?,?,?,?,?)''', entries)
conn.commit()
Upvotes: 1
Views: 48
Reputation: 5630
This is just a guess, as you forgot to show the probably relevant code snippet, that assigns the callback to a tkinter event.
I guess, that you wrote at one place callback()
instead of callback
add a print statement to your callback function and you'll probably see, that callback is called only once, at the moment where you wanted to specify which function to call and that later on when you fill in the form the function is no more called, but you get an error instead.
Perhaps I'm wrong, but ideally you'd write the simplest possible complete program, that allows us to reproduce the error
Upvotes: 2