2017 © Pedro Peláez
 

library sql-split

A simple facility to split SQL files into individual queries - supports MySQL and PostgreSQL

image

kodus/sql-split

A simple facility to split SQL files into individual queries - supports MySQL and PostgreSQL

  • Friday, June 9, 2017
  • by mindplay.dk
  • Repository
  • 4 Watchers
  • 0 Stars
  • 1,629 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 16 % Grown

The README.md

kodus/sql-split

A simple parser to split SQL (and/or DDL) files into individual SQL queries and strip comments., (*1)

PHP Version Build Status, (*2)

Install via Composer

composer require kodus/sql-split

Features

I designed this for use with PDO and MySQL/PostgreSQL statements., (*3)

It uses a very simple recursive descent parser to minimally tokenize valid SQL - this approach ensures there is no ambiguity between quoted strings, keywords, comments, etc. but makes no attempt to validate SQL command structure or validity of the extracted statements., (*4)

It supports the following SQL/DDL features:, (*5)

  • SQL and DDL Queries
  • Stored procedures, functions, views, triggers, etc.
  • PostgreSQL dollar-tags ($$ and $mytag$ delimiters)
  • The MySQL DELIMITER command

Usage

Just this:, (*6)

$statements = Splitter::split(file_get_contents(...));

This will split to individual SQL statements and (by default) strip comments., (*7)

Then just loop over your $statements and run them via PDO., (*8)

That's all., (*9)

The Versions

09/06 2017

dev-master

9999999-dev

A simple facility to split SQL files into individual queries - supports MySQL and PostgreSQL

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

09/06 2017

1.0.0

1.0.0.0

A simple facility to split SQL files into individual queries - supports MySQL and PostgreSQL

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires