Create table in constructor
This commit is contained in:
parent
7a8b027716
commit
a663450c26
|
@ -6,6 +6,7 @@ class Database(object):
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.conn = sqlite3.connect(path)
|
self.conn = sqlite3.connect(path)
|
||||||
self.table_name = "log"
|
self.table_name = "log"
|
||||||
|
self.create_log_table()
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
|
@ -25,7 +26,7 @@ class Database(object):
|
||||||
self.commit()
|
self.commit()
|
||||||
|
|
||||||
def insert(self, log_entry: LogEntry):
|
def insert(self, log_entry: LogEntry):
|
||||||
query = f"INSERT INTO {self.table_name} (name, fingerprint, start, end, duration, filecount) VALUES(?,?,?,?,?)"
|
query = f"INSERT INTO {self.table_name} (name, fingerprint, start, end, filecount) VALUES(?,?,?,?,?)"
|
||||||
self.conn.execute(query, (log_entry.name, log_entry.fingerprint, log_entry.start_time, log_entry.end_time,
|
self.conn.execute(query, (log_entry.name, log_entry.fingerprint, log_entry.start_time, log_entry.end_time,
|
||||||
log_entry.file_count))
|
log_entry.file_count))
|
||||||
self.commit()
|
self.commit()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user