codriao / utils /database.py
Raiff1982's picture
Create utils/database.py
3287512 verified
raw
history blame contribute delete
402 Bytes
import sqlite3
class Database:
def __init__(self, db_path=":memory:"): # Defaults to an in-memory database
self.connection = sqlite3.connect(db_path)
def execute(self, sql, params=()):
cursor = self.connection.cursor()
cursor.execute(sql, params)
self.connection.commit()
return cursor.fetchall()
def close(self):
self.connection.close()