简体   繁体   中英

sqlalchemy doesn't recognize my mysql database

Im trying to connect with SQLAlchemy to Mysql database on my localhost. It throws in an error message saying that the database doesn't exist, which it does. I created it in the Workbench, and used it in other scripts.

My commands in the python shell

from sqlalchemy import create_engine
engine = create_engine("mysql+mysqlconnector://username:password@127.0.0.1:3306/databaseName")
conn=engine.connect()

This is pretty much according to the documentation [here][1].

The complete error message:

ProgrammingError: (mysql.connector.errors.ProgrammingError) 1049 (42000): 
Unknown database 'databaseName'

Does anyone have any idea what it is that goes wrong? Any help is appreciated!

**[1]: http://docs.sqlalchemy.org/en/latest/dialects/mysql.html#module-sqlalchemy.dialects.mysql.mysqlconnector

well, I'd say, databaseName does not exist in your local MySQL database. Be aware, despite MySQL is not case sensitive at column names, etc., it is very sensitive when talking about database names. So make sure, that it's really databaseName , not databasename nor any other weird combination.

Btw, use localhost instead of 127.0.0.1 in your connection string.

Regards, Thomas

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM