Solved

Dynamic database connection with published parameters

  • 13 November 2017
  • 3 replies
  • 9 views

Badge +2

Hi,

I am working on a workflow that can do some simple calculations on different data sets but within just one database of my choosing. Each project has its own database with tables(data sets) and i would like to connect to them by just giving FME the pXXX project number and data set number. I tried to use published parameters to set the same values that i normally use in a more static workflow. This ends up in an error when adding the reader.

Undefined macro `database' dereferenced in file `'
Program Terminating
Translation FAILED.
Workspace generation failed.  Parameter file was C:\Users\Jeroen.GPA\AppData\Local\Temp\FME_1510569791750_7796.

Is it not possible to set the database into a parameter or do i need to save it as something else than text? Or is there another way to get dynamic connections to different databases on the same server(login credentials are the same for all tables and databases on that host and port).

edit: i, of course, filled in the host, port and other information that is missing in naamloos.pgn.

icon

Best answer by jeroen 15 November 2017, 11:23

View original

3 replies

Userlevel 4
Badge +25

You could use actual database connections (Tools -> FME Options -> Database Connections) if you're on FME 2016 or up. If you want to continue using embedded parameters you can try hardcoding them into the workspace when you're creating it and then replacing it with user parameters later on, rather than user parameters right from the start.

Badge +2

parameters.pngThanks, got a bit further with this.

I got the changing of the database working when adding an embedded connection parameters to a new MariaDB reader and just connect to an existing project. After this changing the SourceDataset_MYSQL and connecting it to my own 'database' parameter changes the database to other projects. Unfortunately the feature_type is not changeable after this so making it (for now) impossible to the right table.

Badge +2

I got it working with SQL creator connecting to the database.

Format: MariaDB

Dataset: Embed Connection Parameters 

Go to the parameters and fill in your information but place $(database) into the database parameter. As a Parameters leave attributes to expose empty and connect SQL Statement to a user parameter (multiline). 

I can now use SQL statements to get the table and subtables that i need for the calculations i wanted to do.

SELECT M.link  
,M.f4 AS f4  
,Kf35.f2 AS f35  
,Kf36.f2 AS f36  
FROM 1m1 M  
LEFT JOIN 1k35 Kf35 ON M.f35=Kf35.id  
LEFT JOIN 1k36 Kf36 ON M.f36=Kf36.id 

Reply