mysql - Handling Local and Remote DB in Django -


I am using Django and MySQL to serve a website. My site has my own MySQL server on a local host. Now I have a third-party MySQL database which I need to use to read and write, which is on a remote host. I set up new database information in my settings.py file, but when I try to access remote db then problem comes as new db is not created by me, so I have no related files in models.py There is no square. Regularly read it from Model.objects.using ('remote_db_name'). Get (pk = 0) does not work because it throws a numerator.

I was wondering what is the correct way to handle both a local and remote database in Django, especially when the remote database only gives you SELECT and INSERT privileges. I've found that all the tutorials are about the many databases defined in the same Django site, so all data is required in the models.py file.

Thanks for any help in advance!

You have two options:

  1. your current Use Django to automatically create the model for the database.

  2. Skip the Django ORM, and use raw SQL to execute SQL statements against the database.


Comments