__all__ = ['xsetbg_db_path', 'xsetbg_db']
import os
-from sqlobject import SQLObject, StringCol, IntCol, BoolCol, dberrors
+from sqlobject import SQLObject, connectionForURI, sqlhub, \
+ StringCol, IntCol, BoolCol, dberrors
from xsetbg_conf import xsetbg_conf
-class XSetbg(SQLObject):
+class SqliteSequence(SQLObject):
+ class sqlmeta:
+ idName = 'rowid'
+ name = StringCol(unique=True)
+ seq = IntCol()
+
+
+class XSetBg(SQLObject):
path = StringCol(alternateID=True)
- last_shown = IntCol(default=None) # timestamp
+ last_shown = IntCol(default=None) # timestamp
flag = BoolCol(default=None)
break
if xsetbg_db_path:
+ sqlhub.processConnection = \
+ connectionForURI('sqlite:///%s?debug=1&debugOutput=1' % xsetbg_db_path)
try:
- XSetbg.setConnection('sqlite:///' + xsetbg_db_path)
- XSetbg.select()[0]
+ XSetBg.select()[0]
+ except IndexError:
+ xsetbg_db = XSetBg # Table exists but is empty
except dberrors.Error:
xsetbg_db = None
else:
- xsetbg_db = XSetbg
+ xsetbg_db = XSetBg
else:
xsetbg_db = None