Skip to main content
Question

Get data from most recent database?


aron
Supporter
Forum|alt.badge.img+16
  • Supporter

We have a series of databases (postgis) that get _year_month added to their endings so that we can see which one is the newest. The rest of the name, schema etc is the same.

It would be convenient to have our workspaces automatically look for the most recent database.

So if there exists: supercooldatabase_21_09, supercooldatabase_23_07 and supercooldatabase_24_03 on the server I would like to have FME check all supercooldatabase’s and select the one with the higest number, aka _24_03. This attribute would then be passed on to guide FeatureReaders correctly.

Would it possible to do this within FME?

3 replies

dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • March 14, 2024

If it’s a file geodatabase, you can do this with the Directory and File Pathnames reader. The name of the file will be in the path_windows, with which you can use a TestFilter to get the file with the latest date. Then, pass that path_windows attribute into the FeatureReader.


aron
Supporter
Forum|alt.badge.img+16
  • Author
  • Supporter
  • March 14, 2024

Oh, I forgot. It’s a postgis database. 


nielsgerrits
VIP
Forum|alt.badge.img+55
aron wrote:

Oh, I forgot. It’s a postgis database. 

One way to do this is to use a SQLCreator to get all databases with

select datname from pg_database;

and work from there. Filter the one you need. Use Embed Connection Parameters and set the database name dynamically in a SQLExecutor or a FeatureReader,


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