jeudi 2 août 2018

Laravel DB::raw COPY

im using Laravel 5.5 and I have a very large file that i need to insert its content into the postgres database. In my research i saw the COPY function from Postgresql documentation. Copy function documentation.

I tested the command below in the PgAdmin and works fine.

COPY requisitions FROM '/srv/www/billing_log' DELIMITER ',';

So i saw that in Laravel we can use something like DB::raw() to execute this commands in postgres. I try using the below code but nothing happens and its show no errors.

public function insertFile()
{
    DB::raw("COPY requisitions FROM '/srv/www/billing_log' DELIMITER ','");
    return 'OK';
}

The 'OK' is returned and my DB config is working fine on the others methods.

Could somebody help me?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire