Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Hybrid Mysql and MongoDB in Django

I want to use both mysql and mongodb for my auction site.

Product store in MongoDB, Order store in Mysql

http://www.slideshare.net/spf13/hybrid-mongodb-and-rdbms-applications

How can I do this in Django

like image 348
anhlt Avatar asked Aug 23 '12 09:08

anhlt


People also ask

Can we use MongoDB and MySQL together?

It's common to use MySQL as the primary storage and MongoDB as caching/intermediate storage for speed. You can for example have read-intensive data in MongoDB. The data for generating reports is perfect for a relational system like MySQL.

Can we integrate MongoDB with Django?

There are three ways to connect Django to MongoDB: PyMongo: PyMongo is the standard driver through which MongoDB can interact with Django. It is the official and preferred way of using MongoDB with Python. PyMongo provides functionality to perform all the database actions like search, delete, update, and insert.

Can I connect MySQL to Django?

Django officially supports the following databases: PostgreSQL. MariaDB. MySQL.

How fetch data from MySQL to Django?

Process to get MySQL data So, we need to create the model of the data and implement that model into the db of django. Open 'models.py' and put in the following code. The database table 'students' will be created by the following code. Suppose we have the following records in the 'students' table.


1 Answers

First use standard rdbms database backend. Next try to add django-nonrel/django_mongodb_engine . Django supports multiple databases.

settings.py
DATABASES = {
   'default': {   
'ENGINE': 'django.db.backends.mysql',
    'USER': 'mysql_user',
    'PASSWORD': 'priv4te'
    },

   'product_db' : {
      'ENGINE' : 'django_mongodb_engine',
      'NAME' : 'my_database'
   }
}
  1. https://docs.djangoproject.com/en/dev/topics/db/multi-db/
  2. http://www.allbuttonspressed.com/projects/django-nonrel#documentation
  3. https://github.com/django-nonrel/mongodb-engine
like image 189
baklarz2048 Avatar answered Sep 19 '22 17:09

baklarz2048