def __init__(self, path, conf): self.path = os.path.expanduser(path) self.conf = conf rv = self.execute([ "SELECT name FROM sqlite_master" " WHERE type='table' AND name IN ('threads', 'comments', 'preferences')" ]).fetchone() self.preferences = Preferences(self) self.threads = Threads(self) self.comments = Comments(self) self.guard = Guard(self) if rv is None: self.execute("PRAGMA user_version = %i" % SQLite3.MAX_VERSION) else: self.migrate(to=SQLite3.MAX_VERSION) self.execute([ 'CREATE TRIGGER IF NOT EXISTS remove_stale_threads', 'AFTER DELETE ON comments', 'BEGIN', ' DELETE FROM threads WHERE id NOT IN (SELECT tid FROM comments);', 'END' ])
def __init__(self, path, conf): self.path = os.path.expanduser(path) self.conf = conf self.host = conf.get('mysql', 'host') self.user = conf.get('mysql', 'user') self.passwd = conf.get('mysql', 'passwd') self.db = conf.get('mysql', 'db') rv = None self.preferences = Preferences(self) self.threads = Threads(self) self.comments = Comments(self) self.guard = Guard(self)
def __init__(self, path, conf): self.path = os.path.expanduser(path) self.conf = conf rv = self.execute([ "SELECT name FROM sqlite_master" " WHERE type='table' AND name IN ('threads', 'comments', 'preferences')" ]).fetchone() self.execute([ 'CREATE TABLE IF NOT EXISTS access (', ' id INTEGER PRIMARY KEY, uri VARCHAR(256) UNIQUE, key VARCHAR(256))' ]).fetchone() self.preferences = Preferences(self) self.threads = Threads(self) self.comments = Comments(self) self.guard = Guard(self) if rv is None: self.execute("PRAGMA user_version = %i" % SQLite3.MAX_VERSION) else: self.migrate(to=SQLite3.MAX_VERSION)