在教程中: http ://alembic.readthedocs.org/en/latest/tutorial.html 我通过以下命令测试了自动生成迁移功能:
alembic revision --autogenerate -m "Added account table"
并得到错误:
Traceback (most recent call last):
File "/usr/local/bin/alembic", line 9, in <module>
load_entry_point('alembic==0.3.4', 'console_scripts', 'alembic')()
File "/usr/local/lib/python2.7/dist-packages/alembic-0.3.4-py2.7.egg/alembic/config.py", line 229, in main
**dict((k, getattr(options, k)) for k in kwarg)
File "/usr/local/lib/python2.7/dist-packages/alembic-0.3.4-py2.7.egg/alembic/command.py", line 93, in revision
script.run_env()
File "/usr/local/lib/python2.7/dist-packages/alembic-0.3.4-py2.7.egg/alembic/script.py", line 188, in run_env
util.load_python_file(self.dir, 'env.py')
File "/usr/local/lib/python2.7/dist-packages/alembic-0.3.4-py2.7.egg/alembic/util.py", line 185, in load_python_file
module = imp.load_source(module_id, path, open(path, 'rb'))
File "alembic/env.py", line 20, in <module>
from myapp.mymodel import Base
ImportError: No module named myapp.mymodel
我只是在学习alembic,也从未使用过python。myapp.mymodel 是否已经存在,或者我需要使用 python 创建它。怎么做?非常感谢你!