已有184人关注
e起去旅行网站运行命令创建迁移脚本出错(python manage.py db migrate)
发表在Python图书答疑 2020-08-05 悬赏:15 学分 《Python从入门到项目实践》第29章 e起去旅行网站
是否精华
版块置顶:

执行命令python manage.py db migrate后出错,前面的步骤都跟上了,求解!

错误如下:

The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "manage.py", line 26, in <module>

    manager.run()

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\flask_script\__init__.py", line 417, in run

    result = self.handle(argv[0], argv[1:])

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\flask_script\__init__.py", line 386, in handle

    res = handle(*args, **config)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\flask_script\commands.py", line 216, in __call__

    return self.run(*args, **kwargs)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\flask_migrate\__init__.py", line 197, in migrate

    version_path=version_path, rev_id=rev_id)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\alembic\command.py", line 176, in revision

    script_directory.run_env()

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\alembic\script\base.py", line 427, in run_env

    util.load_python_file(self.dir, 'env.py')

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\alembic\util\pyfiles.py", line 81, in load_python_file

    module = load_module_py(module_id, path)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\alembic\util\compat.py", line 83, in load_module_py

    spec.loader.exec_module(module)

  File "<frozen importlib._bootstrap_external>", line 728, in exec_module

  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

  File "migrations\env.py", line 87, in <module>

    run_migrations_online()

  File "migrations\env.py", line 72, in run_migrations_online

    connection = engine.connect()

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\engine\base.py", line 2102, in connect

    return self._connection_cls(self, **kwargs)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\engine\base.py", line 90, in __init__

    if connection is not None else engine.raw_connection()

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\engine\base.py", line 2188, in raw_connection

    self.pool.unique_connection, _connection)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\engine\base.py", line 2162, in _wrap_pool_connect

    e, dialect, self)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1476, in _handle_dbapi_exception_noconnection

    exc_info

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\util\compat.py", line 203, in raise_from_cause

    reraise(type(exception), exception, tb=exc_tb, cause=cause)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\util\compat.py", line 186, in reraise

    raise value.with_traceback(tb)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\engine\base.py", line 2158, in _wrap_pool_connect

    return fn()

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\pool.py", line 345, in unique_connection

    return _ConnectionFairy._checkout(self)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\pool.py", line 784, in _checkout

    fairy = _ConnectionRecord.checkout(pool)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\pool.py", line 532, in checkout

    rec = pool._do_get()

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\pool.py", line 1280, in _do_get

    return self._create_connection()

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\pool.py", line 350, in _create_connection

    return _ConnectionRecord(self)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\pool.py", line 477, in __init__

    self.__connect(first_connect_check=True)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\pool.py", line 667, in __connect

    connection = pool._invoke_creator(self)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\engine\strategies.py", line 106, in connect

    return dialect.connect(*cargs, **cparams)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\sqlalchemy\engine\default.py", line 410, in connect

    return self.dbapi.connect(*cargs, **cparams)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\pymysql\__init__.py", line 90, in Connect

    return Connection(*args, **kwargs)

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\pymysql\connections.py", line 699, in __init__

    self.connect()

  File "X:\Users\Administrator\Desktop\python\29\Travel\venv\lib\site-packages\pymysql\connections.py", line 967, in connect

    raise exc

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '127.0.0.1' ([WinError 10061] 由于目标计算机积极拒绝,无法连接。)") (Background on this error at: http://sqlalche.me/e/e3q8)


分享到:
精彩评论 1
andy
学分:2118 LV10
TA的每日心情
继续努力
2017-02-06 23:42:34
2020-08-06
沙发

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '127.0.0.1'

意思是没有连接上MySQL。找到config配置文件,修改为你的mysql数据库用户名和密码。参数使用说明手册。

首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照