-
-
Notifications
You must be signed in to change notification settings - Fork 280
Closed
Labels
Description
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.1.0
SQLAlchemy version
2.0.41
RDBMS vendor
PostgreSQL
What happened?
This is related to #423 but I'm not using geoalchemy though I am using pgvector which could be the problem?
Effectively did the same thing and didn't lock sqlacodegen to a version and rebuild introduced the error in my workflow. When I run sqlacodegen 3.1.0 against my remote database suddenly started throwing this error. Locking to 3.0.0 resolves the issue.
My Dockerfile file looks like this:
# Use a Python version compatible with sqlacodegen (e.g., Python 3.11)
FROM python:3.10-slim
# Install build tools and any database client libraries you may need (e.g., for PostgreSQL)
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip and setuptools
RUN pip install --upgrade pip setuptools
# Install sqlacodegen
RUN pip install sqlacodegen
RUN pip install sqlalchemy
RUN pip install psycopg2
RUN pip install black==24.4.2
RUN pip install pgvector
RUN pip install sqlacodegen[pgvector]
# Set work directory (optional)
WORKDIR /workspace
With 3.1.0 I get this error:
sqlacodegen-data-pipelines | /usr/local/lib/python3.10/site-packages/sqlacodegen/generators.py:798: SAWarning: Cannot correctly sort tables; there are unresolvable cycles between tables "Primer, PrimerVersion", which is usually caused by mutually dependent foreign key constraints. Foreign key constraints involving these tables will not be considered; this warning may raise an error in a future release.
sqlacodegen-data-pipelines | for table in self.metadata.sorted_tables:
sqlacodegen-data-pipelines | Traceback (most recent call last):
sqlacodegen-data-pipelines | File "/usr/local/bin/sqlacodegen", line 7, in <module>
sqlacodegen-data-pipelines | sys.exit(main())
sqlacodegen-data-pipelines | File "/usr/local/lib/python3.10/site-packages/sqlacodegen/cli.py", line 150, in main
sqlacodegen-data-pipelines | Using pgvector 0.4.1
sqlacodegen-data-pipelines | outfile.write(generator.generate())
sqlacodegen-data-pipelines | File "/usr/local/lib/python3.10/site-packages/sqlacodegen/generators.py", line 187, in generate
sqlacodegen-data-pipelines | rendered_models = self.render_models(models)
sqlacodegen-data-pipelines | File "/usr/local/lib/python3.10/site-packages/sqlacodegen/generators.py", line 1122, in render_models
sqlacodegen-data-pipelines | rendered.append(self.render_class(model))
sqlacodegen-data-pipelines | File "/usr/local/lib/python3.10/site-packages/sqlacodegen/generators.py", line 1142, in render_class
sqlacodegen-data-pipelines | self.render_column_attribute(column_attr)
sqlacodegen-data-pipelines | File "/usr/local/lib/python3.10/site-packages/sqlacodegen/generators.py", line 1267, in render_column_attribute
sqlacodegen-data-pipelines | rendered_column_python_type = self.render_column_python_type(column)
sqlacodegen-data-pipelines | File "/usr/local/lib/python3.10/site-packages/sqlacodegen/generators.py", line 1261, in render_column_python_type
sqlacodegen-data-pipelines | column_python_type = f"{pre}{render_python_type(col_type)}{post}"
sqlacodegen-data-pipelines | File "/usr/local/lib/python3.10/site-packages/sqlacodegen/generators.py", line 1246, in render_python_type
sqlacodegen-data-pipelines | python_type = column_type.python_type
sqlacodegen-data-pipelines | File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py", line 643, in python_type
sqlacodegen-data-pipelines | raise NotImplementedError()
sqlacodegen-data-pipelines | NotImplementedError
sqlacodegen-data-pipelines exited with code 1
Database schema for reproducing the bug
No response
Reactions are currently unavailable