Reputation: 4803
try:
engine = create_engine('mysql+pymysql:///mysqladmin:***@***.us-west-2.rds.amazonaws.com:3306/peopledb')
print "Opened database successfully";
except Exception as e:
print("Error during connection: ", str(e))
print engine.table_names()
I am attempting to use SQLAlchemy and PyMySQL to connect to a database in AWS RDS. The above code errors on the final line, when I access engine.table_names(). The error I receive is:
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 10061] No connection could be made because the target machine actively refused it)")
Obviously I am not trying to connect to my localhost, I am connecting/connected to a remote host.
Also I was able to successfully connect and access the database using native PyMySQL commands, this issue has to do with SQLAlchemy.
Thanks in advance!
Upvotes: 2
Views: 634
Reputation: 4803
Well, I feel dumb.
There is an extra forward-slash (/) in my connection string that was ruining it. :(
Thanks anyways!
Upvotes: 1