diff options
| author | Diego Roversi <diego.roversi@gmail.com> | 2019-07-20 19:04:48 +0200 | 
|---|---|---|
| committer | Diego Roversi <diego.roversi@gmail.com> | 2019-07-20 19:04:48 +0200 | 
| commit | d34b039a46594da1a6e3ec00972a8b03a0752d22 (patch) | |
| tree | 3e55167872e40de4a3dc192dd236b2a7a7c36fab | |
| parent | 91b60ad164f85aba3c5fcdc0f78453c711a995c5 (diff) | |
save ojbects as json instead as blob
| -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)') | 
