An open API service indexing awesome lists of open source software.

https://github.com/lajosbencz/php-stream-parse-sql

PHP library to parse large SQL files command-by-command
https://github.com/lajosbencz/php-stream-parse-sql

php sql streaming-parser

Last synced: 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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:

```php
$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