1. Go to this page and download the library: Download harish81/laravel-duckdb library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
# Using DB facade
DB::connection('my_duckdb')
->table(base_path('genderdata.csv'))
->where('Gender', '=', 'M')
->limit(10)
->get();
# Using Raw queries
DB::connection('my_duckdb')
->select("select * from '".base_path('genderdata.csv')."' limit 5")
# Using Eloquent Model
class GenderDataModel extends \Harish\LaravelDuckdb\LaravelDuckdbModel
{
protected $connection = 'my_duckdb';
public function __construct()
{
$this->table = base_path('genderdata.csv');
}
}
...
GenderDataModel::where('Gender','M')->first()