Raiff1982 commited on
Commit
3287512
·
verified ·
1 Parent(s): 10032b3

Create utils/database.py

Browse files
Files changed (1) hide show
  1. utils/database.py +14 -0
utils/database.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sqlite3
2
+
3
+ class Database:
4
+ def __init__(self, db_path=":memory:"): # Defaults to an in-memory database
5
+ self.connection = sqlite3.connect(db_path)
6
+
7
+ def execute(self, sql, params=()):
8
+ cursor = self.connection.cursor()
9
+ cursor.execute(sql, params)
10
+ self.connection.commit()
11
+ return cursor.fetchall()
12
+
13
+ def close(self):
14
+ self.connection.close()