17 lines
576 B
Python
17 lines
576 B
Python
|
import sqlite3
|
||
|
from logger import log
|
||
|
|
||
|
class LocalConnector:
|
||
|
def __init__(self, config):
|
||
|
self.db_path = config['Local']['db_path']
|
||
|
self.max_rows = int(config['Local']['max_rows'])
|
||
|
|
||
|
def execute(self, query):
|
||
|
try:
|
||
|
with sqlite3.connect(self.db_path) as conn:
|
||
|
cursor = conn.cursor()
|
||
|
cursor.execute(query)
|
||
|
return cursor.fetchmany(self.max_rows)
|
||
|
except Exception as e:
|
||
|
log.error(f"Local DB error: {str(e)}")
|
||
|
raise ConnectionError("Local storage unavailable")
|