tkivelip/laravel-sql-executer

Laravel SQL Executer

dev-master 2018-12-18 23:11 UTC

This package is auto-updated.

Last update: 2024-09-19 11:44:34 UTC


README

Find more laravel stuff on my new organization account Laramate

Laravel SQL Executer

This package allows you to execute SQL statements from files directly or queued. It uses Laravel's disk Feature, so it is possible to use remote filesystems, too.

This is an easy way to import, seed and transform data very quickly by writing just SQL statements to a file.

Installation

You can install the package via composer:

composer require tkivelip/laravel-sql-executer

How to use?

Using Artisan Console Commands

You can use Artisan to execute a SQL File. If you like to execute the SQL file directly, use the sql-executer:run command:

php artisan sql-executer:run relative/path/file.sql

If you like to queue the execution of a SQL file, use the sql-executer:queue command.

php artisan sql-executer:queue relative/path/file.sql

Using within your application

You can use Laravel's Artisan::call() method within your code to execute or queue a SQL file:

use Illuminate\Support\Facades\Artisan;

// Execute directly
Artisan::call('sql-executer:run', [
    'file' => 'relative/path/file.sql'
]);

// Queue execution
Artisan::call('sql-executer:queue', [
    'file' => 'relative/path/file.sql'
]);

Options

You can configure the commands by the following options.

On both commands:
  • --disk=name Name of the disk to use
  • --sql-connection=name Name of the SQL connection to use
On queue command:
  • --queue=name Name of the queue to use

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.