我正在使用python 2.6,sqlalchemy 0.6用于小型桌面应用程序。此外,我正在使用py2exe和sqlalchemy-migrate,我正在尝试在exe内部集成迁移。这样,当用户启动应用程序时,数据库会自动升级。
如果我尝试在我的eclipse项目中使用migrate,它运行良好,但我想使用py2exe在exe中释放项目本身。不幸的是,当我启动exe时,我得到了错误:
Traceback (most recent call last):
File "sagra.py", line 7, in <module>
File "guiutil.pyc", line 3, in <module>
File "bo.pyc", line 4, in <module>
File "database.pyc", line 26, in <module>
File "<string>", line 2, in version_control
File "migrate\versioning\util\__init__.pyc", line 160, in with_engine
File "migrate\versioning\api.pyc", line 248, in version_control
File "migrate\versioning\schema.pyc", line 128, in create
File "migrate\versioning\repository.pyc", line 76, in __init__
File "migrate\versioning\repository.pyc", line 97, in verify
migrate.versioning.exceptions.InvalidRepositoryError: db_repository
但是目录db_repository和迁移脚本正确地位于py2exe使用的“library.zip”中,以包含我的软件使用的所有python资源。
似乎sqlalchemy-migrate没有在zip中搜索存储库的目录。
这里的问题(repository.py):
def verify(cls, path):
"""
Ensure the target path is a valid repository.
:raises: :exc:`InvalidRepositoryError <migrate.versioning.exceptions.InvalidRepositoryError>`
"""
# Ensure the existence of required files
try:
cls.require_found(path)
cls.require_found(os.path.join(path, cls._config))
cls.require_found(os.path.join(path, cls._versions))
except exceptions.PathNotFoundError, e:
raise exceptions.InvalidRepositoryError(path)
如何从zip读取存储库? 有没有人尝试(并成功)在py2exe生成的exe中使用sqlalchemy-migrate?
感谢您的帮助