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