Ability to print/compile OnConflictDoUpdate statement

Issue #3929 closed
Emmanuel Robert created an issue

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)

  1. Log in to comment