- changed status to closed
Ability to print/compile OnConflictDoUpdate statement
Issue #3929
closed
Dear all, I am using the OnConflictDoUpdate functionality of PostgreSQL, but I have troubles printing SQL statements (for debugging/ understanding).
Is there something special to do to print these statements that are specific to PostgreSQL ? Of course, when I execute the query it works very well.
insert_stmt = insert(table).from_select(select_stmt.columns, select_stmt)
upsert_stmt = insert_stmt.on_conflict_do_update(
constraint=table.primary_key,
set_={fieldName: insert_stmt.excluded[fieldName]}
)
print str(upsert_stmt) # error
print str(upsert_stmt.compile(dialect='postgresql')) # error
Here is the error : UnsupportedCompilationError: Compiler <sqlalchemy.sql.compiler.StrSQLCompiler object at 0x7f5b22460a90> can't render element of type <class 'sqlalchemy.dialects.postgresql.dml.OnConflictDoUpdate'>
Thanks a lot
Comments (1)
-
repo owner - Log in to comment
Hi there -
note that per the guidelines this is not a proper bug report, it is a mailing list question. Please use the mailing list for usage questions.
To print SQLAlchemy core objects as strings please refer to the FAQ at How do I render SQL expressions as strings, possibly with bound parameters inlined?.
thanks!