I would like to connect my DjangoApp to an external MySQL database. I don't want to make migrations to this table, I mean I don't want to create new tables ,just pull data. And my question is - how to do this ? If i add this table to DATABASES in my settings file then the console shows an error about mandatory migration.
What can you recommend me ? Thanks in advance,
you can connect to the external database with this
settings.configure(
DATABASE_ENGINE = 'mysql',
DATABASE_NAME = 'db_name',
DATABASE_USER = 'db_user',
DATABASE_PASSWORD = 'db_pass',
DATABASE_HOST = 'http://YourDataBaseAdress.com/mydatabase',
DATABASE_PORT = '6676',
TIME_ZONE = 'America/Sao_Paulo',) //if you want to connect this forever add this
'CONN_MAX_AGE': None,
and with for no migration you can do
class Meta:
managed = False
for pulling data from external databases you can see here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With