Skip to content

lajosbencz/php-stream-parse-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-stream-parse-sql

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

About

PHP library to parse large SQL files command-by-command

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published