Show More
@@ -195,7 +195,7 b' class SQLiteDB(BaseDB):' | |||
|
195 | 195 | |
|
196 | 196 | If a bad (old) table does exist, return False |
|
197 | 197 | """ |
|
198 | cursor = self._db.execute("PRAGMA table_info(%s)"%self.table) | |
|
198 | cursor = self._db.execute("PRAGMA table_info('%s')"%self.table) | |
|
199 | 199 | lines = cursor.fetchall() |
|
200 | 200 | if not lines: |
|
201 | 201 | # table does not exist |
@@ -241,7 +241,7 b' class SQLiteDB(BaseDB):' | |||
|
241 | 241 | ) |
|
242 | 242 | previous_table = self.table |
|
243 | 243 | |
|
244 | self._db.execute("""CREATE TABLE IF NOT EXISTS %s | |
|
244 | self._db.execute("""CREATE TABLE IF NOT EXISTS '%s' | |
|
245 | 245 | (msg_id text PRIMARY KEY, |
|
246 | 246 | header dict text, |
|
247 | 247 | metadata dict text, |
@@ -333,12 +333,12 b' class SQLiteDB(BaseDB):' | |||
|
333 | 333 | d['msg_id'] = msg_id |
|
334 | 334 | line = self._dict_to_list(d) |
|
335 | 335 | tups = '(%s)'%(','.join(['?']*len(line))) |
|
336 | self._db.execute("INSERT INTO %s VALUES %s"%(self.table, tups), line) | |
|
336 | self._db.execute("INSERT INTO '%s' VALUES %s"%(self.table, tups), line) | |
|
337 | 337 | # self._db.commit() |
|
338 | 338 | |
|
339 | 339 | def get_record(self, msg_id): |
|
340 | 340 | """Get a specific Task Record, by msg_id.""" |
|
341 | cursor = self._db.execute("""SELECT * FROM %s WHERE msg_id==?"""%self.table, (msg_id,)) | |
|
341 | cursor = self._db.execute("""SELECT * FROM '%s' WHERE msg_id==?"""%self.table, (msg_id,)) | |
|
342 | 342 | line = cursor.fetchone() |
|
343 | 343 | if line is None: |
|
344 | 344 | raise KeyError("No such msg: %r"%msg_id) |
@@ -346,7 +346,7 b' class SQLiteDB(BaseDB):' | |||
|
346 | 346 | |
|
347 | 347 | def update_record(self, msg_id, rec): |
|
348 | 348 | """Update the data in an existing record.""" |
|
349 | query = "UPDATE %s SET "%self.table | |
|
349 | query = "UPDATE '%s' SET "%self.table | |
|
350 | 350 | sets = [] |
|
351 | 351 | keys = sorted(rec.keys()) |
|
352 | 352 | values = [] |
@@ -361,13 +361,13 b' class SQLiteDB(BaseDB):' | |||
|
361 | 361 | |
|
362 | 362 | def drop_record(self, msg_id): |
|
363 | 363 | """Remove a record from the DB.""" |
|
364 | self._db.execute("""DELETE FROM %s WHERE msg_id==?"""%self.table, (msg_id,)) | |
|
364 | self._db.execute("""DELETE FROM '%s' WHERE msg_id==?"""%self.table, (msg_id,)) | |
|
365 | 365 | # self._db.commit() |
|
366 | 366 | |
|
367 | 367 | def drop_matching_records(self, check): |
|
368 | 368 | """Remove a record from the DB.""" |
|
369 | 369 | expr,args = self._render_expression(check) |
|
370 | query = "DELETE FROM %s WHERE %s"%(self.table, expr) | |
|
370 | query = "DELETE FROM '%s' WHERE %s"%(self.table, expr) | |
|
371 | 371 | self._db.execute(query,args) |
|
372 | 372 | # self._db.commit() |
|
373 | 373 | |
@@ -399,7 +399,7 b' class SQLiteDB(BaseDB):' | |||
|
399 | 399 | else: |
|
400 | 400 | req = '*' |
|
401 | 401 | expr,args = self._render_expression(check) |
|
402 | query = """SELECT %s FROM %s WHERE %s"""%(req, self.table, expr) | |
|
402 | query = """SELECT %s FROM '%s' WHERE %s"""%(req, self.table, expr) | |
|
403 | 403 | cursor = self._db.execute(query, args) |
|
404 | 404 | matches = cursor.fetchall() |
|
405 | 405 | records = [] |
@@ -410,7 +410,7 b' class SQLiteDB(BaseDB):' | |||
|
410 | 410 | |
|
411 | 411 | def get_history(self): |
|
412 | 412 | """get all msg_ids, ordered by time submitted.""" |
|
413 | query = """SELECT msg_id FROM %s ORDER by submitted ASC"""%self.table | |
|
413 | query = """SELECT msg_id FROM '%s' ORDER by submitted ASC"""%self.table | |
|
414 | 414 | cursor = self._db.execute(query) |
|
415 | 415 | # will be a list of length 1 tuples |
|
416 | 416 | return [ tup[0] for tup in cursor.fetchall()] |
General Comments 0
You need to be logged in to leave comments.
Login now