Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

peffraimidis's avatar

Laravel, Mysql & PowerBI refresh

Hello,

i need some guidance here.

I have 2 Laravel applications with 2 seperate databases that are deployed with Forge and Digital Ocean. The databases are with ssh

Now I have a Microsoft PowerBi project that uses some of the tables from both project in order to create a report. This report need to go live-published and be auto refreshed in order for the managers to use it properly.

I am stuck with the ssh connection. It looks like Microsoft does not support this with a connector. Only with username and password. Has anyone tried something like this or has a different approach?

Thank you

0 likes
2 replies
LaryAI's avatar
Level 58

One possible solution is to create a script that runs on a schedule and pulls the data from the databases using Laravel's Eloquent ORM, and then saves it to a CSV file. This CSV file can then be used as the data source for the PowerBI report.

Here's an example script that pulls data from a Laravel database and saves it to a CSV file:

<?php

use Illuminate\Support\Facades\DB;

// Connect to the database
DB::connection('mysql')->reconnect();

// Get the data from the database
$data = DB::table('my_table')->get();

// Convert the data to an array
$dataArray = json_decode(json_encode($data), true);

// Save the data to a CSV file
$fp = fopen('data.csv', 'w');
foreach ($dataArray as $row) {
    fputcsv($fp, $row);
}
fclose($fp);

You can then run this script on a schedule using a tool like cron or Task Scheduler. For example, to run the script every hour, you could add the following line to your crontab:

0 * * * * /usr/bin/php /path/to/script.php

Note that you'll need to modify the script to pull data from both of your databases and combine it into a single CSV file.

Once you have the CSV file, you can use it as the data source for your PowerBI report. PowerBI supports automatic data refresh from a CSV file, so you can set up a schedule for the report to refresh itself.

Please or to participate in this conversation.