Home Ask Login Register

Developers Planet

Your answer is one click away!

aras February 2016

using mysql and mongodb in django1.8

I am creating a django web application in which I need to use both mysql and mongodb.

I have used mongoengine for this thus:


In my django/settings.py:

       'ENGINE': "django.db.backends.mysql",
        'NAME': "dbname",
        "USER": "username",
        "PASSWORD": "password",
        "HOST": "localhost",
        "PORT": "3306",

How can I configure one more connection for MongoDB here and use it to return in routers.py

I'm using Django 1.8, so I cannot use django-norel/django-mongodb-engine.


the flash February 2016

    'default': {
        "ENGINE": "django.db.backends.mysql",
        "NAME": "dbname",
        "USER": "username",
        "PASSWORD": "password",
        "HOST": "localhost",
        "PORT": "3306",
    'users': {
        'NAME': 'user_data',
        'ENGINE': 'django.db.backends.mysql',
        'USER': 'mysql_user',
        'PASSWORD': 'priv4te'

The migrate management command operates on only one database at a time. By default, it operates on the default database, but by providing a --database argument, you can tell migrate to synchronize a different database. So, to synchronize all models onto all databases, you would need to call:

$ ./manage.py migrate
$ ./manage.py migrate --database=users

I hope it helps.

Post Status

Asked in February 2016
Viewed 2,642 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life