export dashboard data to sql server

export dashboard data to sql server

Urvi_Sukharamwala
Not applicable
170 Views
3 Replies
Message 1 of 4

export dashboard data to sql server

Urvi_Sukharamwala
Not applicable

[ FlexSim 24.0.1 ]

Hello, Is it possible to export data collected/shown graphically in flexsim dashboard to SQL server? If yes, please share the steps to do that. Thank you.


I read this: https://answers.flexsim.com/questions/154040/is-it-possible-to-access-data-in-this-dashboard-ta.html

but I want steps to convert dashboard to statistics collectors as well.

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

jason_lightfoot_adsk
Autodesk
Autodesk
Accepted solution

The steps to expose the already present stats collector from a dashboard chart are to install it.

The way to export the data to a database is to use a Database.Connector and query the (now installed) StatsCollector and use the database's INSERT INTO clause (the syntax changes depending on the specific database).

This is already described in the post to which you linked.

0 Likes
Message 3 of 4

Urvi_Sukharamwala
Not applicable
Thank you. Can you please tell me the script for exporting the data from stats collector to database?
0 Likes
Message 4 of 4

jason_lightfoot_adsk
Autodesk
Autodesk

It will be something like this (sqlite example):

Database.Connection con=Database.Connection("SQLiteConnection");
int connected=con.isConnected;
if (!connected)
    connected=con.connect();
    
if (connected){
    Database.PreparedStatement statement=con.prepareStatement("INSERT INTO StatsCollectorData VALUES(:Time,:Object,:Staytime)");
    Table collector = Table("Staytime Collector");
    int numrows=collector.numRows;
    for (int i = 1; i <= numrows; i++) {
        statement.bindParam("Time", collector["Time"], Database.DataType.DateTime);
        statement.bindParam("Object", StatisticsCollector.getPathFromID(collector["Object"]), Database.DataType.VarChar);
        statement.bindParam("Staytime", collector["Staytime"], Database.DataType.Double);
        statement.execute();
    }    
}

if (connected)
    con.disconnect();

Model and db attached:


WriteStatsCollectorToSQLiteDB.fsm

TestDB.zip


0 Likes