Search code examples
pythonorm

Python is there an ORM for SQL and NoSQL


I am building an app that I want to publish, I will write the app in Python. I don't want to lock down the use of any specific database sql/nosql to my app. How can I design the app or model layer to not enforce a SQL/NOSQL way to store the data.

Is there an ORM that plays with both type of storage? I didn't find one. Normally I would use sqlalchemy to make sure people can use MySQL/PostgreSQL/MSSQL/etc if they want, but adding the NOSQL to the picture seems more complicated than I initially thought.

I have some requirements like:

  • I don't want to enforce any storage backend, this is to ensure that it doesn't scare people from using the app.
  • it must support data schema migration (during installation or upgrade procedures)

If you have any idea how I can architecture these requirements I would appreciate the help. Is it possible to create a structure like this:

    +-----+
    + app +
    +-----+
       |
+-------------+
+ Data Access +
+-------------+
        |
+-----------+
+ SQL/NOSQL +
+-----------+

Thanks


Solution

  • No there is nothing like that.

    An ORM or a RDBMS can rely on SQL as minimal standard for abstracting the underlaying database. Most ORM are build on top of the Python DB API (which is implemented more or less complete by all RDBMS Python bindings).

    For NoSQL there is neither a standard query language nor a standard driver API.

    So there is nothing like that that works for both worlds.

    There have been approaches for defining a common query language for NoSQL language.

    For example there is JsonIQ

    http://www.jsoniq.org/

    But there is not much that help you in reality.