PHPackages                             harish81/laravel-duckdb - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. harish81/laravel-duckdb

ActiveLibrary[Database &amp; ORM](/categories/database)

harish81/laravel-duckdb
=======================

DuckDB CLI wrapper to interact with duckdb databases through laravel query builder.

v1.0.3(2y ago)307.0k11[2 issues](https://github.com/harish81/laravel-duckdb/issues)MITPHPPHP ^8.1

Since Mar 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/harish81/laravel-duckdb)[ Packagist](https://packagist.org/packages/harish81/laravel-duckdb)[ Docs](https://github.com/harish81/laravel-duckdb)[ RSS](/packages/harish81-laravel-duckdb/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (15)Versions (11)Used By (0)

DuckDB CLI wrapper to interact with duckdb databases through laravel query builder.
===================================================================================

[](#duckdb-cli-wrapper-to-interact-with-duckdb-databases-through-laravel-query-builder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0b4d3403d0e14a47556ca597678a42b5d75008042f29198e04f90cbb15b22dbe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68617269736838312f6c61726176656c2d6475636b64622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/harish81/laravel-duckdb)[![Total Downloads](https://camo.githubusercontent.com/d9e605c9bcc07614f60e8cc279f1f63e5a1266d71e5ae444bd995d16217fd3f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68617269736838312f6c61726176656c2d6475636b64622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/harish81/laravel-duckdb)

- Download CLI (either)
    -
    -
    - run `php artisan laravel-duckdb:download-cli` (Experimental)
    - You can also pass argument `--ver` for specific version like `php artisan laravel-duckdb:download-cli --ver=0.7.1`

Support us
----------

[](#support-us)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require harish81/laravel-duckdb
```

Usage
-----

[](#usage)

- Connect

```
'connections' => [
    'my_duckdb' => [
        'driver' => 'duckdb',
        'cli_path' => env('DUCKDB_CLI_PATH', base_path('vendor/bin/duckdb')),
        //'dbfile' => env('DUCKDB_DB_FILE', '/tmp/duck_main.db'),
    ],
...
```

- Examples

```
# 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()
```

Advanced Usage
--------------

[](#advanced-usage)

You can install duckdb extensions too.

### Query data from s3 files directly.

[](#query-data-from-s3-files-directly)

- in `database.php`

```
'connections' => [
    'my_duckdb' => [
        'driver' => 'duckdb',
        'cli_path' => env('DUCKDB_CLI_PATH', base_path('vendor/bin/duckdb')),
        'cli_timeout' => 0, //0 to disable timeout, default to 1 Minute (60s)
        'dbfile' => env('DUCKDB_DB_FILE', storage_path('app/duckdb/duck_main.db')),
        'pre_queries' => [
            "SET s3_region='".env('AWS_DEFAULT_REGION')."'",
            "SET s3_access_key_id='".env('AWS_ACCESS_KEY_ID')."'",
            "SET s3_secret_access_key='".env('AWS_SECRET_ACCESS_KEY')."'",
        ],
        'extensions' => ['httpfs'],
    ],
    ...
```

- Query data

```
DB::connection('my_duckdb')
  ->select("SELECT * FROM read_csv_auto('s3://my-bucket/test-datasets/example1/us-gender-data-2022.csv') LIMIT 10")
```

### Writing a migration

[](#writing-a-migration)

```
return new class extends Migration {
    protected $connection = 'my_duckdb';
    public function up(): void
    {
        DB::connection('my_duckdb')->statement('CREATE SEQUENCE people_sequence');
        Schema::create('people', function (Blueprint $table) {
            $table->id()->default(new \Illuminate\Database\Query\Expression("nextval('people_sequence')"));
            $table->string('name');
            $table->integer('age');
            $table->integer('rank');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('people');
        DB::connection('my_duckdb')->statement('DROP SEQUENCE people_sequence');
    }
};
```

### Readonly Connection - A solution to concurrent query.

[](#readonly-connection---a-solution-to-concurrent-query)

- in `database.php`

```
    'connections' => [
        'my_duckdb' => [
            'driver' => 'duckdb',
            'cli_path' => env('DUCKDB_CLI_PATH', base_path('vendor/bin/duckdb')),
            'cli_timeout' => 0,
            'dbfile' => env('DUCKDB_DB_FILE', storage_path('app/duckdb/duck_main.db')),
            'schema' => 'main',
            'read_only' => true,
            'pre_queries' => [
                "SET s3_region='".env('AWS_DEFAULT_REGION')."'",
                "SET s3_access_key_id='".env('AWS_ACCESS_KEY_ID')."'",
                "SET s3_secret_access_key='".env('AWS_SECRET_ACCESS_KEY')."'",
            ],
            'extensions' => ['httpfs', 'postgres_scanner'],
        ],
        ...
```

Testing
-------

[](#testing)

- Generate test data

```
# Syntax: ./data-generator.sh
./data-generator.sh 100 _test-data/test.csv
./data-generator.sh 90000000 _test-data/test_big_file.csv
```

- Run Test case

```
composer test
```

Limitations &amp; FAQ
---------------------

[](#limitations--faq)

-

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [harish](https://github.com/harish81)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 96.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Recently: every ~52 days

Total

9

Last Release

942d ago

Major Versions

v0.9.1 → v1.0.12023-03-24

v0.9.2 → v1.0.22023-04-14

v0.9.3 → v1.0.32023-10-20

PHP version history (2 changes)v1.0PHP ^8.1

v0.9PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d48fc31d089c987eaffd643cc0c0455ebf132b3ebc4e66c8bb5638aa829e6198?d=identicon)[harish81](/maintainers/harish81)

---

Top Contributors

[![harish81](https://avatars.githubusercontent.com/u/13818806?v=4)](https://github.com/harish81 "harish81 (27 commits)")[![ranjeetmali](https://avatars.githubusercontent.com/u/47209336?v=4)](https://github.com/ranjeetmali "ranjeetmali (1 commits)")

---

Tags

laravelharish81laravel-duckdb

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/harish81-laravel-duckdb/health.svg)

```
[![Health](https://phpackages.com/badges/harish81-laravel-duckdb/health.svg)](https://phpackages.com/packages/harish81-laravel-duckdb)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
