Home > Blockchain >  Building a REST API using a Python based open source framework and NoSQL backend
Building a REST API using a Python based open source framework and NoSQL backend

Time:08-20

I would like to build a REST API using a NoSQL backend with a Python based open source framework to build the API. This API would run in a cloud environment and the goal is for it to be cloud agnostic and have the ability to be deployed anywhere. It must have some abstraction for the backend database technology. I found that Django REST Framework is exactly what I'm looking for, but the Django ORM only supports RDBMS. In an attempt to enable NoSQL support with Django, it seems a few open source packages have been developed but those projects have been abandoned.

I know it's technically possible to use Amazon DynamoDB or Azure Cosmos DB with Django REST Framework, but as it's not officially supported, it sounds like it would require custom code and deviating from standard configurations to get it to work.

  • Does anyone have an API running for Production use using a NoSQL backend with Django REST framework?
  • With Django REST framework, is it possible to abstract the backend database connections to support different NoSQL database types?
  • Is a framework like Flask better suited for creating a REST API using this type of backend?
  • Are there other REST frameworks available which may provide the functionality required if Django REST framework cannot meet these requirements?

CodePudding user response:

I would go with flask mongodb

CodePudding user response:

It is possible to run Django MongoDB but it is not a good idea.

The main reason is that Django does not have an official support for Mongodb. There is a package called Djongo in which is very unreliable and unfinished that allows you to use Django's ORM but with a lot of flaws. You can check the number of issues into this github repository.

Conversely, you can use PyMongo to connect django with mongodb but bear in mind that you will have to do the queries rawly.

In addition, in terms of dealing with different databases in django, I had done such thing but with Postgres and mongodb where you will have to create a Router class to manage the connections.

In my opinion I would go using Flask and have a look also into FastAPI that is almost similar to Flask but with a better approach to create APIs obviously.

  • Related