Create specific DataBase for the Model

Create specific DataBase for the Model

FelipeCapalbo
Not applicable
21 Views
3 Replies
Message 1 of 4

Create specific DataBase for the Model

FelipeCapalbo
Not applicable

[ FlexSim 24.1.0 ]

I am integrating FlexSim with PostgreSQL to export simulation data, but I've encountered an issue. When running multiple simulation models simultaneously, PostgreSQL only receives data from the model that finishes last, as expected.

For now, I’ve come up with the solution of creating a separate database for each simulation model. In the 'DataBase Connector' module, I first identify that the database being connected to is the default PostgreSQL, then execute a query to create a new database, like this:

Database.Connection connection = Database.Connection("DatabaseConnector"); 
connection.connect();

string dbName = "DB1"; 
string createDBQuery = "CREATE DATABASE \"" + dbName + "\";";

connection.query(createDBQuery);

connection.disconnect();

This works, but the problem is that I want to automatically export the simulation data to this newly created database. Currently, I have to manually change the referenced database in the 'DataBase Connector'.

What would probably solve my issue is a command or query that allows me to specify which database I’m connecting to, or even a way to reference this new database name directly within the 'DataBase Name' field in the 'DataBase Connector'.

1729606359726.png


0 Likes
Accepted solutions (1)
22 Views
3 Replies
Replies (3)
Message 2 of 4

FelipeCapalbo
Not applicable

If I could reference a Global Variable in the "Database Name" field, it would solve my issue, as well.

0 Likes
Message 3 of 4

moehlmann_fe
Observer
Observer
Accepted solution

Have you tried editing the value of the "dbName" node in the connection's attributes?

1729665452911.png

Message 4 of 4

FelipeCapalbo
Not applicable

That's it. Thank you very much!

0 Likes