Skip to main content

Hi all,

I am on FME Server 2018 and try to modify the Directory Watch example (https://knowledge.safe.com/articles/51817/directory-watch-publisher-tutorial-2017.html) so that the uploaded data gets imported into a postgis database. But I am not sure about this approach:

1. is the easyTranslator2 workspace suitable for writing to postgis?

2. Where would I set the credentials for the database?

3. How ist the schema creation done, and how can I decide wether to import into an existing table or drop it and create it new?

Certainly beginners questions, so I would be more than happy if someone could shed light on this.

---Markus

Hi Markus,

Please have a look at this Tutorial, as it might give an answer to some of your questions:

https://knowledge.safe.com/articles/28502/getting-started-with-postgis.html

Cheers,

Egge-Jan


1: It could certainly serve as a starting point. The easyTranslator has a generic writer, allowing the user to pick the format they want, you'd have to replace that with a dedicated PostGIS writer.

2: When you create a PostGIS writer you have the option of embedding the connection credentials in the workspace or, recommended, use a Database Connection for it. That Database Connection gets uploaded to FME Server along with your workspace. It'll happen automatically when you publish the workspace to the server.

3: The PostGIS writer has settings for dropping/truncating existing tables. It can also, if you set it to Dynamic mode, create the schema based on what's coming in. Inserting into existing tables can be done as well, but the feature type names have to match.

However... when it comes to dropping or truncating existing tables in combination with a dynamic input I really think you're going to have to be very careful, especially if this is happening in a production environment. You don't know what's coming in and if you set it to drop existing tables a likely scenario might be:

User A uploads mydata.shp, your workspace creates a table mydata in the PostGIS database and loads the data in there.

User B uploads mydata.tab, your workspace recognizes it's supposed to go to an existing table (the matching is done on the feature type name) so it drops it and then inserts the new data.

At that point you've lost the data from User A.


Reply