Compare commits

..

No commits in common. "826312115c7a87e8af5bf27a4d2c181630130481" and "78c04ef6f3f420935735b5ff1185abba352cc581" have entirely different histories.

3 changed files with 4 additions and 33 deletions

View File

@ -118,13 +118,9 @@ class Table:
with sqlite3.connect(self._state.dbfile, **self._state.dbargs) as conn: with sqlite3.connect(self._state.dbfile, **self._state.dbargs) as conn:
conn.row_factory = sqlite3.Row conn.row_factory = sqlite3.Row
try: try:
col_types = conn.execute("PRAGMA table_info(%s)" % self._table).fetchall()
cur = conn.execute("SELECT * FROM %s %s" % (self._table, where_clause), params) cur = conn.execute("SELECT * FROM %s %s" % (self._table, where_clause), params)
for row in cur: for row in cur:
yield dict( yield dict(row)
(col[0], _deserialize(row[col[0]], col_types[i]["type"]))
for i, col in enumerate(cur.description)
)
except: except:
return None return None
@ -132,13 +128,9 @@ class Table:
with sqlite3.connect(self._state.dbfile, **self._state.dbargs) as conn: with sqlite3.connect(self._state.dbfile, **self._state.dbargs) as conn:
conn.row_factory = sqlite3.Row conn.row_factory = sqlite3.Row
try: try:
col_types = conn.execute("PRAGMA table_info(%s)" % self._table).fetchall()
cur = conn.execute("SELECT * FROM %s" % (self._table,)) cur = conn.execute("SELECT * FROM %s" % (self._table,))
for row in cur: for row in cur:
yield dict( yield dict(row)
(col[0], _deserialize(row[col[0]], col_types[i]["type"]))
for i, col in enumerate(cur.description)
)
except: except:
return None return None
@ -217,7 +209,7 @@ def _serialize(value):
def _deserialize(value, col_type): def _deserialize(value, col_type):
if col_type.lower() == "blob": if col_type == "blob":
return base64.b64decode(value) return base64.b64decode(value)
return value return value

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup( setup(
name="hexlib", name="hexlib",
version="1.81", version="1.79",
description="Misc utility methods", description="Misc utility methods",
author="simon987", author="simon987",
author_email="me@simon987.net", author_email="me@simon987.net",

View File

@ -110,24 +110,3 @@ class TestPersistentState(TestCase):
del s["a"][456] del s["a"][456]
except Exception as e: except Exception as e:
self.fail(e) self.fail(e)
def test_deserialize_get_set(self):
s = PersistentState()
s["a"][0] = {"x": b'abc'}
self.assertEqual(s["a"][0]["x"], b'abc')
def test_deserialize_sql(self):
s = PersistentState()
s["a"][0] = {"x": b'abc'}
self.assertEqual(list(s["a"].sql("WHERE 1=1"))[0]["x"], b'abc')
def test_deserialize_iter(self):
s = PersistentState()
s["a"][0] = {"x": b'abc'}
self.assertEqual(list(s["a"])[0]["x"], b'abc')