Spaces:
Runtime error
Runtime error
Create utils/database.py
Browse files- 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()
|