Serialization / De-serialization for SQLAlchemy Declarative ORM

130 views
Skip to first unread message

chris.mo...@insightindustry.com

unread,
Jul 11, 2018, 4:00:58 PM7/11/18
to sqlalchemy
Hi Folks,

First off, I'd just like to thank everyone here for all of the awesome work you've been doing on SQLAlchemy. I've been using the library for years, and it is a truly fantastic piece of code that I rely on literally every day. Thank you for all the work that you've done and are doing - it is deeply appreciated.

Some time ago, I was thinking about how I might be able to give back to the SQLAlchemy community, and I realized that I often find myself extending my SQLAlchemy base models with serialization and de-serialization functionality (usually to/from JSON and CSV, sometimes YAML or XML). And since it's the type of thing I've done numerous times in various API and data science-related projects, I thought it probably makes sense to abstract the functionality out and package the logic for re-use.

Separation of concerns being important, I don't think this is functionality that would be good to build into SQLAlchemy's codebase directly, so instead I wrote it as a new library I'm calling SQLAthanor which I've just released to PyPi.

It works as a drop-in replacement for parts of the SQLAlchemy ORM (particularly Declarative) that extends models with serialization/de-serialization support, granting the ability to:
  • serialize/de-serialize to/from CSV, JSON, YAML, and Python dict
  • serialize/de-serialize columns, relationships, hybrid properties, association proxies, and Python @property attributes
  • enable/disable serialization for particular attribute/format combinations
  • execute pre/post-processing functions on inbound/outbound data
Since this is a new project, v.0.1.0 is only released on PyPi in beta at the moment. I've got - I think - pretty extensive tests written, but as we all know, database connectivity is all about edge cases. As it stands, my test matrix covers Python 2.7, 3.4, 3.5, and 3.6 with versions of SQLAlchemy going all the way back to 0.9.

If you're interested, I'd be incredibly grateful for any thoughts, feedback, suggestions, wish lists, or questions you might have. And (if you do try to use SQLAthanor in a project) any and all issues you stumble across would also be incredibly helpful.

Here are the relevant links if you'd like to take a look:

DOCUMENTATION: https://sqlathanor.readthedocs.io/en/latest (I hope comprehensive!)



Thanks in advance, and I look forward to any thoughts or perspectives you might have!

All the best,
Chris

Mike Bayer

unread,
Jul 11, 2018, 6:26:55 PM7/11/18
to sqlal...@googlegroups.com
Hi Chris -

congratulations! this looks extremely well documented and it's clear
you put an enormous amount of effort into it! I will definitely
point users your way when they ask for this kind of thing. Looks
great.

- mike
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+...@googlegroups.com.
> To post to this group, send email to sqlal...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

chris.mo...@insightindustry.com

unread,
Jul 11, 2018, 7:25:04 PM7/11/18
to sqlalchemy
Hi Mike,

Thanks - I really appreciate it! 

And thanks again for all of the effort you've put into SQLAlchemy! It is a "must have" in most of the Python projects I work on these days, and I regularly sing its praises to my clients.

All the best,
Chris

Jonathan Vanasco

unread,
Jul 11, 2018, 10:44:38 PM7/11/18
to sqlalchemy
this looks great, and omfg the docs!
Reply all
Reply to author
Forward
0 new messages