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
- Host: GitHub
- URL: https://github.com/lajosbencz/php-stream-parse-sql
- Owner: lajosbencz
- License: gpl-3.0
- Created: 2020-01-16T14:30:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-20T17:27:05.000Z (over 5 years ago)
- Last Synced: 2025-02-10T09:42:07.078Z (4 months ago)
- Topics: php, sql, streaming-parser
- Language: PHP
- Size: 39.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-stream-parse-sql
PHP library to parse large SQL files command-by-commandIt'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