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.
composer require lajosbencz/stream-parse-sql
$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);
}
- Extensively test if any input can produce a malformed command