Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
628 views
in Technique[技术] by (71.8m points)

python - sqlalchemy.ext.automap: using PyInstaller (4.1, 4.2) results in KeyError ("sqlalchemy/util/_collections.py", line 212)

from sqlalchemy import create_engine
from sqlalchemy.ext.automap import automap_base

DB_PATH = "path/to/db.sqlite3"

# SQLAlchemy
engine = create_engine(f"sqlite:////{DB_PATH}")
Base = automap_base()
Base.prepare(engine, reflect=True)

# Tables from database
Apps = Base.classes.Apps
Files = Base.classes.Files

The code works but after compiling it into a binary using PyInstaller:

   Traceback (most recent call last):
       File "sqlalchemy/util/_collections.py", line 210, in __getattr__
       KeyError: 'Apps'

   During handling of the above exception, another exception occurred:
  
   Traceback (most recent call last):
       File "Script", line 64, in <module>
       File "sqlalchemy/util/_collections.py", line 212, in __getattr__
   AttributeError: Apps
   [18627] Failed to execute script Script

All the tables have integer primary keys, I've also tried to compile it by adding "--add-data ./pyenv/lib/python3.9/site-packages/SQLAlchemy-1.3.22.dist-info/*:SQLAlchemy-1.3.22.dist-info"

question from:https://stackoverflow.com/questions/65903651/sqlalchemy-ext-automap-using-pyinstaller-4-1-4-2-results-in-keyerror-sqlal

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...