lajosbencz / stream-parse-sql
PHP library to parse large SQL files command-by-command
v0.1.1
2020-01-20 16:53 UTC
Requires
- php: >=7
This package is auto-updated.
Last update: 2024-12-21 04:35:37 UTC
README
PHP library to parse large SQL files command-by-command
It's not a real SQL parser though, it only cares about command integrity, but not syntax.
Install:
composer require lajosbencz/stream-parse-sql
Usage:
$parser = new LajosBencz\StreamParseSql\StreamParseSql("./my/large/file.sql"); $parser->onProgress(function($position, $size) { echo ($position / $size) * 100, PHP_EOL; }); foreacH($parser->parse() as $sqlCommand) { /** @var stdClass $myDb some database adapter */ $myDb->execute($sqlCommand); }
Todo:
- Extensively test if any input can produce a malformed command