Forums

To test MySql connection

Hello, could you please tell me how to test mysql database connection in Django? Not using the console but with a little script that simply say if mysql is succesfully connected or not?

Sorry, I'm a bit confused -- how would you run the script if not from the console?

Cannot be created a script that attempt to connect to the database and to tell if the connection has been done succesfully or not? As an app for educational purpose :)

do you mean you write the script using our file editor and then hit save and run?

or do you mean you want a http endpoint that tries to access the database and returns the result?

http endpoint that tries to access the database and returns the result. is there a tutorial to do that?

If you have a django app and try to access the database when the connection isn't working, it will raise an exception. You probably don't even need a special endpoint for that, just use an existing view that accesses the database - if you get an error, then the database connection is not working.

Ok thanks