python - using mysql and mongodb in django1.8 -
i creating django web application in need use both mysql , mongodb.
i have used mongoengine thus:
mongoengine.connect("mongodb://username:password@localhost:27017/dbname")
in django/settings.py:
databases = { 'default': 'engine': "django.db.backends.mysql", 'name': "dbname", "user": "username", "password": "password", "host": "localhost", "port": "3306", }
how can configure 1 more connection mongodb here , use return in routers.py
i'm using django 1.8, cannot use django-norel/django-mongodb-engine
.
databases = { '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 1 database @ time. default, operates on default database, providing a --database
argument, can tell migrate synchronize different database. so, synchronize models onto databases, need call:
$ ./manage.py migrate $ ./manage.py migrate --database=users
i hope helps.
Comments
Post a Comment