I have a python script with Tkinter and I want to print in background each queries did in Sqlite database (just for the fun):
I have one Database Object:
import sqlite3
class Database():
def __init__(self):
try:
sqlite3.enable_callback_tracebacks(True)
self.connection = sqlite3.connect('databases.sqlite')
self.cursor = self.connection.cursor()
self.cursor.execute( """ CREATE TABLE .... """ )
except:
print('error in database connection')
def __del__(self):
self.cursor.close()
And a Task object
class Task():
def __init__(self, name="no_name"):
self.database = Database()
data = {"name" : name }
self.database.cursor.execute("INSERT INTO tasks(name) VALUES(:name)" , data )
self.database.connection.commit()
And when I did this new_task = Task('Hello')
I want an automatic outpout in CLI like this:
* executed in 4ms :
INSERT INTO tasks (name) VALUES('Hello');
Any idea? Thank you in advance!