question

Felipe Capalbo avatar image
0 Likes"
Felipe Capalbo asked Felix Möhlmann answered

Create specific DataBase for the Model

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


FlexSim 24.1.0
database connectorpostgresql
1729606359726.png (18.9 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered

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

1729665452911.png


1729665452911.png (9.4 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

That's it. Thank you very much!

0 Likes 0 ·
Felipe Capalbo avatar image
0 Likes"
Felipe Capalbo answered

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

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.