Set the row_factory for the sqlite3.Connection
This commit is contained in:
parent
8c1d719c9f
commit
87413e45f6
|
@ -39,18 +39,17 @@ class Inventory():
|
||||||
cur.execute('VACUUM')
|
cur.execute('VACUUM')
|
||||||
cur.execute("INSERT INTO status VALUES ('lastvacuumtime', ?)", (now,))
|
cur.execute("INSERT INTO status VALUES ('lastvacuumtime', ?)", (now,))
|
||||||
self._db.commit()
|
self._db.commit()
|
||||||
|
self._db.row_factory = self.__object
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __object(cursor, row):
|
def __object(cursor, row):
|
||||||
|
if len(cursor.description) != 8:
|
||||||
|
return row
|
||||||
vector, expires, obj_type, version, stream, tag, data, offset = row
|
vector, expires, obj_type, version, stream, tag, data, offset = row
|
||||||
return structure.Object(
|
return structure.Object(
|
||||||
expires, obj_type, version, stream, data, offset,
|
expires, obj_type, version, stream, data, offset,
|
||||||
tag=tag, vector=vector)
|
tag=tag, vector=vector)
|
||||||
|
|
||||||
def __objects(self, cur):
|
|
||||||
cur.row_factory = self.__object
|
|
||||||
return cur
|
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
with shared.objects_lock:
|
with shared.objects_lock:
|
||||||
self._db.execute(
|
self._db.execute(
|
||||||
|
@ -73,7 +72,7 @@ class Inventory():
|
||||||
|
|
||||||
cur = self._db.execute(
|
cur = self._db.execute(
|
||||||
'SELECT * FROM objects WHERE ' + ' AND '.join(clauses), params)
|
'SELECT * FROM objects WHERE ' + ' AND '.join(clauses), params)
|
||||||
return self.__objects(cur)
|
return cur
|
||||||
|
|
||||||
def vectors_to_send(self, stream=None):
|
def vectors_to_send(self, stream=None):
|
||||||
cur = self._db.execute(
|
cur = self._db.execute(
|
||||||
|
@ -94,8 +93,7 @@ class Inventory():
|
||||||
return (v for v, in cur)
|
return (v for v, in cur)
|
||||||
|
|
||||||
def values(self):
|
def values(self):
|
||||||
cur = self._db.execute('SELECT * FROM objects')
|
return self._db.execute('SELECT * FROM objects')
|
||||||
return self.__objects(cur)
|
|
||||||
|
|
||||||
def popitem(self):
|
def popitem(self):
|
||||||
if not self.rowid:
|
if not self.rowid:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user