Django App - Accessing Remote MySQL Database

1,204 views
Skip to first unread message

Ji Park

unread,
Aug 1, 2013, 8:50:35 PM8/1/13
to django...@googlegroups.com
Hello, I'm trying to make an app that can periodically access a remote mysql database.

This app will query the remote database and copy some data to the local postgresql database.

So far I know that celery can be used to schedule periodic tasks, but I'm not sure what to do about querying the remote mysql database server.

Should I just use python's MySQLdb module, does anyone know any other python module that I can use to query mysql db?

Would this even be a good way to access remote database server from a django app? I'll have to be running a function that is within tasks.py periodically (via celery-django), would there be any better way to access remote mysql server from a django app in this case?

Branko Majic

unread,
Aug 2, 2013, 8:58:38 AM8/2/13
to django...@googlegroups.com
Depends on whether you want ORM or not, I guess. You could use
SQLAlchemy or even Django's database abstraction for accessing the
remote database.

As a side-note, I hope you won't be pumping data directly to database
used by Django (i.e. raw) - since you'll be bypassing all model checks
that you may have built-in in your models.

Best regards

--
Branko Majic
Jabber: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
Џабер: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.
signature.asc

Christian Schmitt

unread,
Aug 2, 2013, 9:26:23 AM8/2/13
to django...@googlegroups.com
You could use django's inbuild ORM:
And just copy the database.

Ji Park

unread,
Aug 2, 2013, 12:27:57 PM8/2/13
to django...@googlegroups.com, bra...@majic.rs
I was actually thinking about updating local database with raw data, but now that you mention it, I think I'd rather not.

Ji Park

unread,
Aug 2, 2013, 12:29:49 PM8/2/13
to django...@googlegroups.com
Thanks! I've just started really getting into Django, I had no idea there was a way to connect multiple databases and still be able to use django's ORM to control them.

Liam Griffin

unread,
Oct 3, 2013, 1:54:16 PM10/3/13
to django...@googlegroups.com
I have a MySQL server with hundreds of dbs... is there a way to be able to connect to all these without breaking DRY principles?
Reply all
Reply to author
Forward
0 new messages