KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Datasource not found #577

Closed Ronnie Oficiar opened this topic on on Dec 28, 2018 - 8 comments

Ronnie Oficiar commented on Dec 28, 2018

Please help..

Im doing Koolreport/laravel friendship but with DATASOURCE NOT FOUND error.

 function setup()
    {
        // Let say, you have "sale_database" is defined in Laravel's database settings.
        // Now you can use that database without any futher setitngs.
        $this->src("larastart")
        ->query("SELECT * FROM users")
        ->pipe($this->dataStore("users"));        
    }

My .env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=larastart
DB_USERNAME=root
DB_PASSWORD=

Thank you

KoolReport commented on Dec 28, 2018

As you only have 1 default connection and you don't give the name for it, please use $this->src("default"). Please let me know if it works.

Ronnie Oficiar commented on Dec 28, 2018

Datasource not found 'default'

function setup()

{
    // Let say, you have "sale_database" is defined in Laravel's database settings.
    // Now you can use that database without any futher setitngs.
    $this->src("default")
    ->query("SELECT * FROM users")
    ->pipe($this->dataStore("users"));        
}

I thougt ->src() should have the databasename as parameter.

thank you for the prompt reply.

KoolReport commented on Dec 28, 2018

If you open the config/database.php of Laravel, do you see something like this:

'default' => env('DB_CONNECTION', 'mysql'),

At the connections, do you see list of database connection which contains the settings for mysql somethign like this:

    'connections' => [

        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'automaker'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],
Ronnie Oficiar commented on Dec 28, 2018

Thank you very much... report already displaying..

KoolReport commented on Dec 28, 2018

Awesome :) may I know what went wrong? It may benefit other who have the same situation as yours.

Ronnie Oficiar commented on Dec 28, 2018
function setup()
{
    // Let say, you have "sale_database" is defined in Laravel's database settings.
    // Now you can use that database without any futher setitngs.
    $this->src("mysql")
    ->query("SELECT * FROM users")
    ->pipe($this->dataStore("users"));        
}

$this->src("default") should be $this->src("mysql")

Again, thank you.

KoolReport commented on Dec 28, 2018

I see, great!

Craig vc commented on Jan 21, 2019

does it not make sense to use the .env variables?

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

Laravel