sqlacodegen error

26 views
Skip to first unread message

Ivy Chang

unread,
Jul 1, 2020, 3:49:20 PM7/1/20
to sqlalchemy
Hello, I'm running sqlacodegen for the first time, and it works successfully for most tables, but for some tables I'm getting the following error:

>sqlacodegen mssql+pymssql://... --outfile db.py --tables MyTable

Traceback (most recent call last):
  File "C:\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "d:\dev\E2EAPIs\env\Scripts\sqlacodegen.exe\__main__.py", line 9, in <module>
  File "d:\dev\e2eapis\env\lib\site-packages\sqlacodegen\main.py", line 53, in main
    generator.render(outfile)
  File "d:\dev\e2eapis\env\lib\site-packages\sqlacodegen\codegen.py", line 699, in render
    rendered_models.append(self.render_class(model))
  File "d:\dev\e2eapis\env\lib\site-packages\sqlacodegen\codegen.py", line 679, in render_class
    self.indentation, attr, self.render_column(column, show_name))
  File "d:\dev\e2eapis\env\lib\site-packages\sqlacodegen\codegen.py", line 573, in render_column
    default_expr = self._get_compiled_expression(column.server_default.arg)
AttributeError: 'Computed' object has no attribute 'arg'

Any suggestions?  Thank you!

Mike Bayer

unread,
Jul 1, 2020, 4:00:02 PM7/1/20
to noreply-spamdigest via sqlalchemy
Sqlalchemy has recently added support for computed column defaults, which are different than regular SQL defaults.  The sqlacodegen tool will need to be updated to support this concept.   You can request this via their issue tracker, where it seems this is already being discussed at https://github.com/agronholm/sqlacodegen/issues/116 .
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages