Download the PHP package thomas-0816/pdo-duckdb-php without Composer
On this page you can find all versions of the php package thomas-0816/pdo-duckdb-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thomas-0816/pdo-duckdb-php
More information about thomas-0816/pdo-duckdb-php
Files in thomas-0816/pdo-duckdb-php
Package pdo-duckdb-php
Short Description PHP PDO Driver for DuckDB, modern analytics
License MIT
Informations about the package pdo-duckdb-php
PHP PDO Driver for DuckDB
DuckDB is an embedded SQL database designed for high-performance analytics (OLAP).
pdo_duckdb is a native DuckDB database driver for the PHP Data Objects (PDO) interface.\
As a native PHP extension, it is implemented in C/C++ and does not require PHP FFI or preloading.\
Compared to FFI, pdo_duckdb offers much more performance and lower latency by processing query results and type conversions in C/C++.
It is also thread safe and fully tested with FrankenPHP (PHP-ZTS) and Swoole.\
The release packages contain pre-compiled binaries for all supported platforms and DuckDB is directly included.
DuckDB extensions work the same way as they do in DuckDB CLI.
This extension supports all DuckDB types: Text, Numeric, Date, Time, Interval, JSON, Array, Struct, Map, List, Tuple, Enum, Variant, Geometry, Union, Bitstring, Blob and Boolean.
Supported PHP versions (nts & zts): 8.2 8.3 8.4 8.5 8.6
Supported operating systems: Ubuntu 22+, Debian 12+, Fedora 42+, openSUSE 16+, AmazonLinux, Arch, Alma, Rocky, Alpine, Wolfi OS, Windows Server 2022/2025 (x64), macOS 15+ (arm64)
Supported SAPIs: php-cli, php-fpm, mod_php, FrankenPHP, TrueAsync, Swoole
Support end: macOS 14 (August 2026), PHP 8.2 (Jan 2027), Ubuntu 22.04 (April 2027), Debian 12 (April 2027)
DuckDB 2.0
DuckDB 2.0 brings many new features:
JSON mutation functions, variant functions, nearest joins, group by UNNEST, triggers, $variable shorthand, async IO, explain (sql), deferred constraints and many more
For a complete list, see What's New in the Docs for 2.0.
More information about migrating to DuckDB v2.0.
v2 backward compatibility settings:
Do I need to update to DuckDB 2.0 immediately?
DuckDB 1.5.x will be supported until 2027-03-01. More about the release calendar.
Install and setup with 🥧 PIE
Install and load on demand with 🥧 PIE
Install and setup with 🧟 FrankenPHP (Debian/Ubuntu)
Install and setup with Docker
Usage examples
Open databases from disk or in-memory
Read and write Parquet files
Apache Parquet: very fast and efficient column based storage file format containing one table of data.\ Each column is split into several column groups. Depending on the query, the file can be read partially by certain columns groups.\ Different compression or dictionary algorithms can be applied to each column. Also supports encryption.
Read CSV files with SQL
CSV data import
Read JSON files with SQL
Read and write Excel files
Use structured columns with a fixed schema
Vector Similarity Search (HNSW)
Views
Transactions
Cast array columns to JSON-string
Auto increment columns
Differences to MySQL / MariaDB
Copy data from MySQL or MariaDB to Parquet
Start MariaDB container, create and fill "orders" table:
Use DuckDB MySQL extension to copy "orders" table from MariaDB to a parquet file:
Copy data from PostgreSQL to Parquet
Start PostgreSQL container, create and fill "orders" table:
Use DuckDB PostgreSQL extension to copy "orders" table from PostgreSQL to a parquet file:
Bulk data insertion
Inserting many rows one by one is slow, use a single query to perform bulk data insertion (1M rows in <1s).
Read public data using HTTPs, JSON, CSV and Parquet
Query weather data:
Download and query historical data from Deutsche Bahn:
Read private data using REST APIs
See the documentation for managing secrets and read_json().
Read data from S3, write data to S3
Start RustFS container, create new "my-bucket" bucket:
Use DuckDB httpfs extension to read and write data from/to S3:
Client-server mode (Quack Remote Protocol)
Start the DuckDB server:
Client connect:
For more information about the Quack Remote Protocol, see the documentation.
Community extensions
open_prompt integrates LLMs into your SQL queries:
More extensions: List of Core Extensions, List of Community Extensions
Note: Community extensions are third party projects, NOT maintained or reviewed by the DuckDB team.
Performance
DuckDB is extremely fast when it comes to analytic queries.\ Here is an example with 10M rows, performing in 170ms on 4 threads with 128M ram:
Security
Use SQL SET variable = value; or put the settings inside the PDO::DUCKDB_ATTR_CONFIG connection options array:
A complete list is available in the DuckDB documentation: Securing DuckDB.
Alternatively, you can run SQL statements when the connection is estabilshed using PDO::DUCKDB_ATTR_INIT_COMMAND:
The DuckDB security model is described here.
Compile NTS
Compile ZTS
Install with Swoole
Swoole example
Client-server mode (Quack Remote Protocol):
Learn more about concurrency in DuckDB.
Compile with PHP TrueAsync
Backup and restore
Backup as .duckdb file:
Backup and restore as SQL + Parquet:
Learn more about export and import statements.
Features not implemented
- Custom UDF scalar functions: requires calling PHP functions in parallel which is not supported by NTS and would be very slow
- Custom UDF table functions: using
select * from json_each('<json_string>')gives better performance and is easier to use - Appender API: using
insert into ... select value->>0, ... from json_each('<json_string>')is easier to use, gives almost the same performance and provides better error handling - open_basedir: only provides security on application level, use real sandboxes like nono or lightweight VMs like firecracker instead
- persistent connections: opening a connection to DuckDB is already very fast, a reset function for the database session is currently not available in DuckDB
- ERRMODE_SILENT, ERRMODE_WARNING: the standard for PHP and all frameworks is ERRMODE_EXCEPTION
Why DuckDB?
Like SQLite, DuckDB embeds directly into host applications as a library, eliminating the need for network serialization and separate server setups. It uses columnar storage and vectorized processing, running analytics 10–100x faster than traditional row-oriented databases. DuckDB spills data to disk if needed, allowing to process datasets much larger than available system RAM. It includes an advanced query optimizer that handles joins, subqueries, expressions and filters.\ DuckDB can directly query flat files (JSON, CSV, and Parquet) directly via SQL without needing to import the data first. Flat files can be read directly from disk, network attached storage or S3 comatible cloud storage.\ Data is processed in cache-friendly batches on a multi-core architecture, allowing modern hardware to operate on arrays of data simultaneously. For analytical queries that only require a few metrics, DuckDB reads only the relevant columns from disk/memory, saving I/O and CPU cycles. This brings data warehouse-level performance to any laptop or server.
FAQ
Do I need an extra server for DuckDB?
No. DuckDB runs completely embedded inside of PHP as an extension, just like SQLite.
How much RAM and CPU do I need for DuckDB?
DuckDB normally runs good with 1-4 GB RAM and 2-4 CPU cores.
How good is the compression with Parquet and zstd?
For logs you normally achieve compression rates of 50-100x.
Who is maintaining DuckDB?
The DuckDB project is owned and maintained by the DuckDB Foundation, a non-profit organization from Amsterdam.
Can I get support for DuckDB?
Yes. Support is available on GitHub, see the community support page for details.
Can I get support for pdo_duckdb?
Yes. Just open an Issue or a Pull request.
Is the PHP PDO Driver for DuckDB developed by the DuckDB project?
No. This is a third-party open-source community project.
Is DuckDB fully open-source?
Yes. DuckDB and all components are fully open-source under the MIT license.
Development
Laravel, Symfony
DuckDB Resources
AI Disclosure
The C code is written by AI, the tests are written without AI.
License
MIT License
All versions of pdo-duckdb-php with dependencies
ext-pdo Version *