basic dynamic menu generation
This commit is contained in:
23
app/db.py
Normal file
23
app/db.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user