开发者

Can i access different database in django than other default database

I have the database backup script in python which inserts some data in mysql database .

Now my Django is in different database.

How can i access different database because i don't have any objects in Mo开发者_运维百科dels.py. i want to display some data in django interface


Yes, you can setup multiple database and access every one of them. you can get the specified database connection cursor using this:

from django.db import connections
cursor = connections['my_db_alias'].cursor()

where my_db_alias is your another db alias .

check the doc:

https://docs.djangoproject.com/en/1.3/topics/db/multi-db/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜