Skip to main content
Best Answer

FME Startup Script

  • April 13, 2020
  • 6 replies
  • 61 views

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

erik_jan
Contributor
Forum|alt.badge.img+26
  • 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+46
  • 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

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+26
  • Contributor
  • April 13, 2020

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

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

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!