SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

Robert Latest boblatest at yahoo.com
Mon Feb 28 16:28:39 EST 2022


Albert-Jan Roskam wrote:
>      The event may have arbitrary, but dict-like data associated with it,
>      which I want to add in the field 'info'.  This data never needs to be
>      modified, once the event has been inserted into the DB.
>
>      What type should the info field have?  JSON, PickleType, String, or
>      something else?
>
>      I couldn't find any really reliable sounding information about the
>      relative
>      pros and cons, apart from a Reddit thread claiming that pickled dicts
>      are larger than dicts converted to JSON or String.

I've done exactly this. Since my data was strictly ASCII I decided to go for
JSON. But in the end you're the only one who can decide this because only you
know the data. That's why you won't find any hard and fast rule for this.


More information about the Python-list mailing list