Reputation: 245
I want to interact with some data from an SQL database in Python, but am having connection issues. I've verified that the information below is correct, as I'm able to use these credentials (stored in a YAML file) to log in to the database via MySQL Workbench 6.3 CE.
user_db : *******
user_host : **********
user_port : 3306
user_username: username
user_password: password
Here is the connection code within my Ipython Notebook:
prod_db = psycopg2.connect(database=credentials['user_db'],
user=credentials['user_username'],
password=credentials['user_password'],
host=credentials['user_host'],
port=credentials['user_port'])
Regardless of whether or not I try to connect using the YAML file or just use the values within it, I get this error in my Ipython Notebook. The line indicated is the 'port' line above.
OperationalError: could not send data to server: Software caused connection
abort (0x00002745/10053)
could not send startup packet: Software caused connection abort
(0x00002745/10053)
I'm able to use identical code to log in to a Redshift database using port 5439, but I'm wondering what is causing this particular error.
Upvotes: 1
Views: 1439
Reputation: 759
It seems like you're trying to connect to MySQL (port 3306) using a PostgreSQL client library (psycopg2), which also works for Redshift because Redshift is based on Postgres.
Please try installing PyMySQL or any of the alternatives.
Upvotes: 3