Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'sqlalchemy' has no attribute '__all__'. Did you mean: '__file__'? #50

Open
nianqinianyi opened this issue Aug 22, 2023 · 4 comments

Comments

@nianqinianyi
Copy link

versions:
python==3.10

PyMySQL==1.1.0
SQLAlchemy==2.0.20
flask-sqlacodegen==2.0.0

error command:
flask-sqlacodegen 'mysql+pymysql://username:password@ip:port/db' --outfile './models.py'

success command:
flask-sqlacodegen 'mysql+pymysql://username:password@ip:port/db' --outfile './models.py' --flask

I want generator the models without flask, so I remove the param '--flask', but it has errors.

when I user old versions of SQLAlchemy, the command run successfully:
PyMySQL==0.9.3
SQLAlchemy==1.3.17
flask-sqlacodegen==1.1.8

@shanghaobo
Copy link

我也遇到这个问题了,请问你最后是怎么解决的?

@nianqinianyi
Copy link
Author

nianqinianyi commented Nov 10, 2023

我也遇到这个问题了,请问你最后是怎么解决的?

没解决,用老版本SQLAlchemy生成,然后拷过来

@ebram96
Copy link

ebram96 commented Jun 26, 2024

@nianqinianyi What is the version that has worked with you?

@siparker
Copy link

on line 230 of codegen.py

change

pkgname = 'sqlalchemy' if type_.__name__ in sqlalchemy.__all__ else type_.__module__

to

pkgname = type_.__module__

Works for me on sqlqlchemy 2.0.27 using flask sqlalchemy 3.1.1 and latest flask_sqlacodegen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants