bootbox/app/db.py

24 lines
604 B
Python
Raw Normal View History

2019-11-18 01:06:28 -05:00
import os
import sqlite3
db_path = '/usr/local/lib/bootbox/local.sqlite3'
class LocalDB(object):
def __init__(self, db_path = db_path):
self.db_path = db_path
self.conn = sqlite3.connect(self.db_path)
self.conn.row_factory = sqlite3.Row
self.cur = self.conn.cursor()
def getMenu(self, menu):
result = []
self.cur.execute('SELECT * FROM {0}'.format(menu))
for row in self.cur.fetchall():
result.append(dict(row))
return(result)
def close(self):
self.cur.close()
self.conn.close()
return()