python:使用SQLAlchemy初始化mysql数据库报错 No module named 'mysql'

FLowUs邀请链接:https://flowus.cn/login?code=AXNU63
FlowUs邀请码:AXNU63


Traceback (most recent call last):
  File "D:\projects\Python\SQLAlchemy\001-demo.py", line 19, in <module>
    engine = create_engine('mysql+mysqlconnector://root:123456@localhost:3306/demo')
  File "D:\Python\Python39\lib\site-packages\sqlalchemy\engine\__init__.py", line 520, in create_engine
    return strategy.create(*args, **kwargs)
  File "D:\Python\Python39\lib\site-packages\sqlalchemy\engine\strategies.py", line 87, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "D:\Python\Python39\lib\site-packages\sqlalchemy\dialects\mysql\mysqlconnector.py", line 135, in dbapi
    from mysql import connector
ModuleNotFoundError: No module named 'mysql'

解决方法

pip install mysql-connector
posted @ 2021-03-05 09:50  wbytts  阅读(545)  评论(0编辑  收藏  举报