0

I need some help. I created a CRUD with Flask, and I want to conect it with my MySQL in azure. I new using Flask, so I don't know how to do it. Somebody can help me?

Now, I tried to do this: app.config['SQLALCHEMY_DATABASE_URI']'mysql://Myuser@Myuser:MyPasswrd@MyDataBase:3306/mySchema'

My localhost works, so, I tried to change the username,passwrd and database and thought that it would work. But it didn't. I can access my Mysql-azure via workbench btw. Thank you for reading!

KarthikBhyresh-MT
  • 4,560
  • 2
  • 5
  • 12

2 Answers2

0

I tried it here, and I got an error, I'll put a photo here. idk if this errors is because I dont have a MySQL connection, or something (I was using but I removed to see if it would work). Here a print of my instance.py and the error Instance of server

0

It should work after installing mysql-connector.

pip install mysql-connector

change the SQLALCHEMY_DATABASE_URI in your python script to below and create your database.

app.config["SQLALCHEMY_DATABASE_URI"] = "mysql+mysqlconnector://{username}:{password}@{server}/testdb".format(username, password, server)

let me know if you see any specific error

KarthikBhyresh-MT
  • 4,560
  • 2
  • 5
  • 12
  • One question, I have to use these .format()? Cause when I not use I receive the error Can't connect to MySQL server on '{my-db}:3306' (-2 Name or service not known) – rodrigo lima Jun 15 '21 at 13:41