jakiboy/pducky 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jakiboy/pducky

最新稳定版本:0.2.0

Composer 安装命令:

composer require jakiboy/pducky

包简介

Run fast SQL queries on massive datasets (CSV, JSON, and Parquet) powered by DuckDB.

README 文档

README

DuckDB PHP adapter

High-performance PHP adapter for DuckDB that executes SQL queries directly on massive datasets (CSV, JSON, Parquet) without preprocessing or imports. Features SQLite-compatible interface, FFI integration, and intelligent CSV parsing for zero-ETL analytics on files up to gigabytes in size.

Benchmark:

Tested with a large CSV dataset containing 1 million rows (150 MB) using PHP v8.3.

Note: No optimizations were applied. The benchmark includes database creation from compressed CSV and query execution.

DuckDB PHP adapter

CPU Memory Disk OS Timing
i7 (13K) 32 Go NVMe Windows 10 Pro x64 2.19s
i7 (8) 8 Go NVMe Windows 10 Pro x64 3.054s
Xeon (E22) 16 Go SSD Linux Debian 11 3.58s
i3 (3) 8 Go SSD Windows 10 Pro x64 30.23s

Requirements:

  • PHP exec function
  • PHP SQLite3 extension
  • PHP FFI extension (Used by Loader)

Install:

composer require jakiboy/pducky
vendor/bin/pducky install-binaries

Test:

git clone https://github.com/Jakiboy/pducky.git
cd pducky && composer dump-autoload
composer install-binaries
cd examples && bash generate.sh
bash test.sh

Examples:

Fetch single value:

$price = (new Pducky\Adapter('data.csv'))->import()->single(
	'SELECT `price` FROM `temp` WHERE `ean` = "4567890123456";'
); // 374.08$

Fetch rows:

$rows = (new Pducky\Adapter('data.csv'))->import()->query(
	'SELECT * FROM `temp` LIMIT 100;'
); // []

Create database:

Create database data with table product from a compressed CSV file data.csv.gz.

(new Pducky\Adapter('data.csv.gz'))->import('data', 'product');

Loader query (FFI):

$rows = (new Pducky\Loader())->connect('data.db')
	   ->importCsv('data.csv', 'product')
	   ->query('SELECT * FROM product LIMIT 100;'); // []

References:

Authors:

⭐ Support:

Skip the coffee! If you like the project, a Star would mean a lot.

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-28