Skip to main content
Solved

FME Startup Script


Forum|alt.badge.img

Is it possible in a startup script to access incoming shapefiles and set a private parameter based on a shapefiles attribute?

For example, I am a reading shapefiles and at the same time I want to query a rather large database based off a unique id that the shapefiles contain. I'm currently using the SQLCreator because it seems to be the fastest database reader.

I was thinking within the startup script, I could set a private or published parameter to a shapefile attribute, then in the SQLCreator, I could have a sql statement, that has db.attname = $(newParameter).

 

Any assistance would be greatly appreciated.

 

Thank you!

Best answer by ebygomm

If you want to read the shapefile and then execute an sql query based on an attribute in the shapefile you can pass a feature containing the attribute to trigger an sqlexecutor and build the sql query using the attribue

View original
Did this help you find an answer to your question?

6 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • April 13, 2020

Hi @david_prosack88,

This process is easily built using the Shape file reader, followed by a Featurereader transformer to read the database.

The FeatureReader can use a WHERE clause, based on the attributes from the Shape file.

Hope this helps.


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • Best Answer
  • April 13, 2020

If you want to read the shapefile and then execute an sql query based on an attribute in the shapefile you can pass a feature containing the attribute to trigger an sqlexecutor and build the sql query using the attribue


Forum|alt.badge.img
erik_jan wrote:

Hi @david_prosack88,

This process is easily built using the Shape file reader, followed by a Featurereader transformer to read the database.

The FeatureReader can use a WHERE clause, based on the attributes from the Shape file.

Hope this helps.

thanks for the suggestion! I guess my only concern is how fast it reads against a database that has millions of records. Is the speed the same compared to the SQLCreator transformer?


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • April 13, 2020
david_prosack88 wrote:

thanks for the suggestion! I guess my only concern is how fast it reads against a database that has millions of records. Is the speed the same compared to the SQLCreator transformer?

Using the WHERE clause, the speed should be exactly the same.

Both transformers (and the database readers) use SQL to read from the database.

The main performance issue occurs if the database table is not indexed on the attribute(s) that are used in the WHERE clause.

But that is the same for SQLCreator and FeatureReader.


Forum|alt.badge.img
erik_jan wrote:

Using the WHERE clause, the speed should be exactly the same.

Both transformers (and the database readers) use SQL to read from the database.

The main performance issue occurs if the database table is not indexed on the attribute(s) that are used in the WHERE clause.

But that is the same for SQLCreator and FeatureReader.

Thanks! You are right. For some reason, I thought the FeatureReader transformer was much slower than the SQLCreator transformer. Thanks for the help, it performs great!


Forum|alt.badge.img
ebygomm wrote:

If you want to read the shapefile and then execute an sql query based on an attribute in the shapefile you can pass a feature containing the attribute to trigger an sqlexecutor and build the sql query using the attribue

Thanks @ebygomm! Your suggestions is another great way to solve my issue. Thanks!


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