diff options
Diffstat (limited to 'tropical/db.py')
| -rw-r--r-- | tropical/db.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tropical/db.py b/tropical/db.py index 431fce8..372f440 100644 --- a/tropical/db.py +++ b/tropical/db.py @@ -1,11 +1,21 @@ import sqlite3, time, socket +def rowFactory(cursor, row): + """ + Create dictionary for each sqlite row + """ + d = {} + for idx, col in enumerate(cursor.description): + d[col[0]] = row[idx] + return d + class CalDB: __DBVERSION__="1" def __init__(self, dbPath): self.path=dbPath self.con=sqlite3.connect(dbPath) + self.con.row_factory = rowFactory self.cur=self.con.cursor() # Init database @@ -34,3 +44,7 @@ class CalDB: Event format: { name: str, calendar: int, desc: str, start: float, end: float, repeat: str, frequency: int } """ pass + + def listEvents(self): + res=self.cur.execute("SELECT * FROM events") + return res.fetchall() |
