Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thbley/php-duckdb-integration
PHP example to integrate DuckDB using PHP-FFI
https://github.com/thbley/php-duckdb-integration
embedded-database php-ffi
Last synced: about 1 month ago
JSON representation
PHP example to integrate DuckDB using PHP-FFI
- Host: GitHub
- URL: https://github.com/thbley/php-duckdb-integration
- Owner: thbley
- License: mit
- Created: 2020-09-26T16:58:11.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-13T11:44:21.000Z (almost 2 years ago)
- Last Synced: 2023-05-05T14:26:19.844Z (over 1 year ago)
- Topics: embedded-database, php-ffi
- Language: C
- Homepage:
- Size: 7.98 MB
- Stars: 26
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
PHP example to integrate DuckDB using PHP-FFI
-----------------------------------------------Currently there is no PHP extension available for using DuckDB, so I created a small library using PHP-FFI.
DuckDB is an embeddable SQL OLAP database management system.
It does not require external servers. Databases are stored in single files (similar to SQLite).
Compared to SQLite, DuckDB is much faster. E.g. I imported 16M rows from a CSV file in 5s on my notebook (i5-8250U).DuckDB can import CSV files with automatic format detection and automatic table creation using:
CREATE TABLE test1 AS SELECT * FROM read_csv_auto('test1.csv');
CREATE TABLE test2 AS SELECT * FROM read_csv_auto('test2.csv.gz');Usage:
php -dffi.enable=1 test.php
or:
docker build -t php-ffi .
docker run -it --rm -v $(pwd):/code php-ffi php /code/test.phpRequirements:
PHP 7.4+ with FFI extension enabled
References:
- Slides: https://github.com/thbley/php-duckdb-integration/blob/master/Getting_started_with_phpffi_ipc_2021_ThomasBley.pdf
- https://duckdb.org
- https://github.com/cwida/duckdb
- https://github.com/cwida/duckdb/releases/latest/download/libduckdb-linux-amd64.zip
- https://www.php.net/manual/en/book.ffi.php