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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…