4

can anyone please help me with it. I was trying to use sqlacodegen with postgresql to autogenerate the database models from my database, but it is constantly showing me this import error

>sqlacodegen postgresql://postgres:j1234@localhost:4040/db1
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Scripts\sqlacodegen.exe\__main__.py", line 4, in <module>
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlacodegen\main.py", line 11, in <module>
    from sqlacodegen.codegen import CodeGenerator
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlacodegen\codegen.py", line 9, in <module>
    from inspect import ArgSpec
ImportError: cannot import name 'ArgSpec' from 'inspect' (C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\inspect.py)

i am working with python 3.11, postgresql, sqlalchemy 2.0.15, and sqlacodegen 2.3.0

I want to autogenerate database models from my database for my fastapi. I am also open to any kind of sqlacodegen alternatives

Juned SK
  • 41
  • 2
  • 1
    `ArgSpec` was removed in python3.11, you have to either use 3.10 or wait for `sqlacodegen` to fix it – python_user May 21 '23 at 08:43
  • Thanks man, youre right. I installed 3.10 version of python and now it is working just fine... God bless you – Juned SK May 21 '23 at 12:48
  • What exactly does ArgSpec get replaced with? No idea even what it did in the first place... some sort of reflection capability? – JGFMK Jul 26 '23 at 11:09

0 Answers0