I am using sqlalchemy core and pugsql, my use case is to use sqlalchemy core's Table and Column classes to create tables and manage migrations via alembic while puqsql will be used to do other types of queries.
After I import puqsql and sqlalchemy's create_engine method I create and instantiate my engine. Then I procced to create an sql connection to the db and pass it to MetaData.create_all.
import sqlalchemy as sa
import puqsql
engine = sa.create_engine(DB_CONN_STR)
sqlmodule = pugsql.module(SQL_PATH)
sqlmodule.setengine(engine)
with engine.connect() as conn:
metadata.create_all(conn)
It is after calling create_all that I get a huge stacktrace and then the final message about maximum recursion depth being exceeded.
I managed to track down the root of the issue with is this piece of code in the pugsql.statment module
@compiles(BindParameter)
def _visit_bindparam(element, compiler, **kw):
cc = getattr(_locals, 'compile_context', None)
if cc:
if _is_expanding_param(element, cc):
element.expanding = True
return compiler.visit_bindparam(element)
I am not very familiar with the internals of sqlalchemy but what does this function do and why is it causing a recursion exceeded runtime error?
I am using sqlalchemy core and pugsql, my use case is to use sqlalchemy core's Table and Column classes to create tables and manage migrations via alembic while puqsql will be used to do other types of queries.
I have these tables
After I import puqsql and sqlalchemy's
create_engine
method I create and instantiate my engine. Then I procced to create an sql connection to the db and pass it toMetaData.create_all
.It is after calling
create_all
that I get a huge stacktrace and then the final message about maximum recursion depth being exceeded.I managed to track down the root of the issue with is this piece of code in the
pugsql.statment
moduleI am not very familiar with the internals of sqlalchemy but what does this function do and why is it causing a recursion exceeded runtime error?
Any insight will be much appreciated.