Skip to content

A validating SQL lexer and parser with a focus on MySQL dialect.

License

Notifications You must be signed in to change notification settings

pranavan15/sql-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Parser

A validating SQL lexer and parser with a focus on MySQL dialect.

Code status

Build Status Code Coverage codecov.io Scrutinizer Code Quality

Installation

Please use Composer to install:

composer require phpmyadmin/sql-parser

Usage

Command line utility

Command line utility to syntax highlight SQL query:

./vendor/bin/highlight-query --query "SELECT 1"

Command line utility to lint SQL query:

./vendor/bin/lint-query --query "SELECT 1"

Formatting SQL query

echo SqlParser\Utils\Formatter::format($query, array('type' => 'html'));

Parsing and building SQL query

$parsed = new SqlParser\Parser($query);

// you can now inspect or change query
var_dump($parser->statements[0]);

// and build it again
$statement = $parser->statements[0];
$statement->build()

More information

This library was originally created during the Google Summer of Code 2015 and has been used by phpMyAdmin since version 4.5.

About

A validating SQL lexer and parser with a focus on MySQL dialect.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%