Reputation: 1
I am trying to connect my Django project with the Azure Mysql database but it's showing this error continuously:
RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': (2003, "Can't connect to MySQL server on 'dummyserver.database.windows.net' (timed out)")
and this is easily able to connect with the Azure Data Studio, don't know why it's not working in this Django Project. even i am able to make the connection to the local Mysql Server and able to migrate the table and models, but when i am trying to do this with Azure Mysql database, then it's not working and I'm sure of all the details i put in the configuration.
i had also followed these links: https://learn.microsoft.com/en-us/samples/azure-samples/azure-sql-db-django/azure-sql-db-django/
i just want to make this connection done and able to migrate all my models to the Azure Mysql database, with the help of my Django project.
Upvotes: 0
Views: 752
Reputation: 3709
Adding to @Mitrajeet Golsangi comments. From the reference MSDOC and git I am able to connect to Connect Azure Mysql Database with Django Project.
For Azure SQL Server.
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'mydb',
'USER': 'user@myserver',
'PASSWORD': 'password',
'HOST': 'myserver.database.windows.net',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
},
},
}
For Azure Mysql
config = { 'host':'<mydemoserver>.mysql.database.azure.com',
'user':'<myadmin>@<mydemoserver>',
'password':'<mypassword>',
'database':'<mydatabase>',
'client_flags': [mysql.connector.ClientFlag.SSL],
'ssl_ca': '<path-to-SSL-cert>/DigiCertGlobalRootG2.crt.pem'
}
Output:
Upvotes: 0