Skip to main content

Hello

I want to export a table from PostGis databse by keeping only the columns that don't appear in a text file.

This is an example to be more clear :

 

Text_file : A B C Z

Table columns :

ID

 

7

 

T

 

Z

 

F

 

K

 

B

 

 

 

 

 

 

 

 

 

Export result:

ID

 

7

 

T

 

F

 

K

 

 

 

 

 

 

 

Thank you in advance for your answers.

Best Regards

You could read the text file and per feature in there have an SQLExecutor perform an ALTER table DROP column query.

However... this screams "massive SQL injection vulnerability" so I would recommend that you make really really sure the input text file is correct.


You could read the text file and per feature in there have an SQLExecutor perform an ALTER table DROP column query.

However... this screams "massive SQL injection vulnerability" so I would recommend that you make really really sure the input text file is correct.

Hello and thank you very much for your answer. Sorry for my late answer.

Do you think there's any other way then this sql query ?

Thank you very much in advance for your answer.


Hello and thank you very much for your answer. Sorry for my late answer.

Do you think there's any other way then this sql query ?

Thank you very much in advance for your answer.

Well... I'm no SQL wizard, but one thing you can try is

  1. Create a view (as SELECT * FROM table)
  2. Drop the columns you don't want from that view (with the ALTER view DROP column)
  3. SELECT * FROM view, run the data through your process
  4. Drop the entire view

Each step is a separate SQLExecutor. It'll leave the original table untouched.


Well... I'm no SQL wizard, but one thing you can try is

  1. Create a view (as SELECT * FROM table)
  2. Drop the columns you don't want from that view (with the ALTER view DROP column)
  3. SELECT * FROM view, run the data through your process
  4. Drop the entire view

Each step is a separate SQLExecutor. It'll leave the original table untouched.

This. But if you are not allowed to create a view (which is often the case in my experience) you also could generate the select query. I can think of two ways:

  1. Use a SQLExecutor to Retrieve all colunms from the table from information_schema.columns. (select * from information_schema.columns where table_schema = 'public' and table_name = 'spatial_ref_sys';)
  2. Get one row (select * from public.spatial_ref_sys limit 1;) and use an AttributeExploder to extract the columns. Remove all columns starting with fme_ using a Tester.

Then use a FeatureMerger to merge with the checklist (Supplier). Unmerged Requestors are the columns not in the checklist. Aggregator to concat all remaining columns, AttributeCreator to create select statement. (select srid,auth_name,auth_srid,srtext,proj4text from public.spatial_ref_sys;) Use a SQLExecutor to run the concatted selectstatement.


Reply