#Connect Python Script to MySQL

16 messages · Page 1 of 1 (latest)

stuck sun
#

Hi there,

I am simply trying to connect a python script to a MySQL instance but I'm getting this error:
_mysql_connector.MySQLInterfaceError: Can't connect to MySQL server on 'localhost:7140' (99)
See the screenshot for my connection code.

nocturne shadowBOT
#

Project ID: 28e5bbc5-449a-46ba-80bd-62e16c4eed9b

stuck sun
#

Project ID: 28e5bbc5-449a-46ba-80bd-62e16c4eed9b

shell shale
#

are you getting this error when both the python script and mysql instance are running on railway?

stuck sun
#

yes

shell shale
#

can you show me a screenshot of your service variables?

stuck sun
#

should I reveal them?

shell shale
#

no no, please show the service variables though, those are the plugin variables

stuck sun
#

ah i see, should I be manually adding those variables here?

shell shale
#

no never add the database variables manually, click the variable references link button, but read this before you get into that, read this

stuck sun
#

Ok it works thanks. Another question, if I have a database table that I want to have pre-loaded without the program needing to create it, what would be a good way for me to do that? Or should I set it up in the code like: if table exists, continue, if not, create it.

shell shale