Skip to main content
Open

Sending SQL statement as it is

Related products:Transformers
hvukasinovic
danilo_fme
antoine
arthur_bazin
kalbert
+2
  • hvukasinovic
    hvukasinovic
  • danilo_fme
    danilo_fme
  • antoine
    antoine
  • arthur_bazin
    arthur_bazin
  • kalbert
    kalbert
  • hydrolithe
    hydrolithe
  • josch
    josch

arthur_bazin
Contributor

Refering to this thread and this other thread, FME is doing a lot of things on our sql statement without asking us...

As a PostgreSQL database engineer, my SQL scripts can be really complex and I want FME to send it to the database wihtout encapsulated it into some darkmagic procedure...

It could be great to have an option to tell FME to send the statement to the database as it is. The dev have to check for the commit part and all of course.

5 replies

arthur_bazin
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • July 15, 2024

I found another situation.

I want to use FME to perfom a VACUUM FULL after a set of operations.

But I can’t with FME because there is no transformer that allows me to send SQL command without being in a transaction block.

It could be great to have an advanced option in the SQLExecutor to avoid packaging our SQL into a transaction block an to sending it just as it is.

It could allow us to perform VACUUM.


rlagarde
Contributor
Forum|alt.badge.img+2
  • Contributor
  • April 16, 2025

You can send a VACUUM Statement to PostgreSQL in the “SQL to Run After Write” parameter of a featureWriter.

Another option would be to run the VACUUM within a “Shutdown Python Script”

 

 


arthur_bazin
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • April 16, 2025

Hi ​@rlagarde ,

Thanks for the advice but unfortunetly it is impossible in my context. I use SQLExecutor to achieve some updates into the database with complexe functions and procedures.

I cannot use a FeatureWriter as it is not the transformer used at this stage of my translation (there is no need to write or update feature into the workspace into the DB).

I cannot use the Shutdown Python Script because there are other operation after that.

I currently use PythonCaller with psycopg to connect to the db and run the VACCUM FULL which works but is unsatisfiying in my opinion.

Pay attention, VACUUM ANALYZE can be run into a translation but VACUUM FULL not ;-)

 


rlagarde
Contributor
Forum|alt.badge.img+2
  • Contributor
  • April 17, 2025

You could put it on the initiator output port of your SQLExecutor

Instead of the featureWriter you could even have a FeatureReader connecting to your postgres database and do the VACUUM FULL in the “run before/after“ of a dummy read on any table.

psycopg will work fine in any case.

Also note that VACUUM ANALYZE won’t run in a transaction. A simple ANALYZE will


arthur_bazin
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • April 17, 2025

Yeah, my mistake, VACUUM alwas run outside of a transaction, regardless of the specified options.

That’s another possibility but like the PythonCaller and the FeatureWriter, those are bypasses and I like clean workspaces ;-)

By the way, thanks for spending time on this subject ! I hope Safe will add this little option for managing the transaction encapsulation.

It could be great to start a transaction inside a transformer, commit it inside another and having plenty of SQL request between these two… Many ideas about this subject 😅


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings