14

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

6 Answers 6

11

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer, I will have to decide then if I prefer going with NoSQL over SQL. I will have a look at jsoniq.
1

The closest I have seen to a abstraction layer is django-nonrel. This is a fork of django, which supports both Mongo, Google's NoSQL database and a few others.

At one time is was promising, but because the django community generally rejected the idea of adding NoSQL, it has fallen behind.

Comments

1

I would suggest you to build a data access layer just before persistent layer, this will give you freedom to choose whaterver orm you want. Obviously you can build your own micro orm.

Comments

0

You should try the www.28.io implementation of JSONiq. Its available as a Cloud service or On premise.

Comments

0

There is a nosql ORM tool. It has almost no dependencies so you can easily convert objects between nosql orm and sql orm tools i guess

Only supports dynamodb and redis for now.

nosqlmodel on gitlab.com

Comments

0

MongoEngine is an object-document mapper (ODM), which is roughly equivalent to an SQL-based object-relational mapper (ORM). MongoEngine provides a class-based abstraction, so all the models you create are classes.

This helps you to avoid creating all the mechanisms for the CRUD operations.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.