diff options
-rw-r--r-- | pyapd/stores/sqlite.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/pyapd/stores/sqlite.py b/pyapd/stores/sqlite.py index fc81ac2..86d569d 100644 --- a/pyapd/stores/sqlite.py +++ b/pyapd/stores/sqlite.py @@ -1,7 +1,6 @@ from .. import objects from . import exceptions -import pickle import sqlite3 @@ -17,9 +16,7 @@ class Store(): c.execute('''insert or replace into objects(type, oid, obj) values ( :type, :oid, :obj )''', - (obj_type, obj.ap_id, sqlite3.Binary( - pickle.dumps(obj, protocol=2))) - ) + (obj_type, obj.ap_id, obj.to_jsons())) self.db.commit() c.close() @@ -36,11 +33,11 @@ class Store(): if row is None: raise exceptions.DoesNotExist( "An object with id {} does not exist".format(oid)) - return pickle.loads(row[0]) + return objects.APObject.from_jsons(row[0]) def createdb(self): c = self.db.cursor() - c.execute('create table objects(type text, oid text, obj blob)') + c.execute('create table objects(type text, oid text, obj text)') c.execute('create unique index idx on objects(type, oid)') |