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

Attribute error module 'sqlalchemy' has no attribute '__all__'. Did you mean: '__file__'? for mysql #334

Open
2 tasks done
Scylla2020 opened this issue Jun 16, 2024 · 2 comments
Labels

Comments

@Scylla2020
Copy link

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Sqlacodegen version

3.0.0b2

SQLAlchemy version

2.0.30

RDBMS vendor

MySQL (or compatible)

What happened?

Im trying to generate the model or a mysql database using sqlacodegen mysql://username:password@127.0.0.1:3307/mydb > models.py and getting an error

Traceback (most recent call last):
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\Scripts\sqlacodegen.exe\__main__.py", line 7, in <module>
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlacodegen\cli.py", line 58, in main
    outfile.write(generator.generate())
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlacodegen\generators.py", line 115, in generate
    models: List[Model] = self.generate_models()
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlacodegen\generators.py", line 622, in generate_models
    self.collect_imports(models_by_table_name.values())
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlacodegen\generators.py", line 138, in collect_imports
    self.collect_imports_for_model(model)
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlacodegen\generators.py", line 569, in collect_imports_for_model
    super().collect_imports_for_model(model)
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlacodegen\generators.py", line 148, in collect_imports_for_model
    self.collect_imports_for_column(column)
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlacodegen\generators.py", line 157, in collect_imports_for_column
    self.add_import(Column)
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlacodegen\generators.py", line 208, in add_import
    elif type_.__name__ in sqlalchemy.__all__:  # type: ignore[attr-defined]
  File "C:\Users\UserX\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\__init__.py", line 294, in __getattr__
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
AttributeError: module 'sqlalchemy' has no attribute '__all__'. Did you mean: '__file__'?

How can I fix this? I've been trying different sqlalchemy versions with no luck

Database schema for reproducing the bug

No response

@Scylla2020 Scylla2020 added the bug label Jun 16, 2024
@agronholm
Copy link
Owner

Have you tried updating your sqlacodegen to the latest pre-release version?

@Scylla2020
Copy link
Author

Thanks that worked!

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

No branches or pull requests

2 participants