{"repo":"iamcal/SQLParser","free":true,"listed":false,"github":"https://github.com/iamcal/SQLParser","clone":"git clone https://github.com/iamcal/SQLParser.git","description":"Parse MySQL schemas in PHP, fast","language":"PHP","stars":77,"topics":["php","sql-parser","lex","composer","database","autoloader"],"license":"MIT","category":"databases-storage","readme_excerpt":"SQLParser - Parse MySQL schemas in PHP, fast This library takes MySQL CREATE TABLE statements and returns a data structure representing the table that it defines. MySQL syntax version 5.7 is supported. This library does not try to validate input - the goal is to deconstruct valid CREATE TABLE statements. Installation You can install this package using composer. To add it to your composer.json : You can then load it using the composer autoloader: If you don't use composer, you can skip the autoloader and include src/SQLParser.php directly. Usage To extract the tables defined in SQL: The tables property is an array of tables, each of which is a nested array structure defining the table's structure: You can also use the lexer directly to work with other piece of SQL: The tokens property contains an array of tokens. SQL keywords are returned as uppercase, with multi-word terms (e.g. DEFAULT CHARACTER SET ) as a single token. Strings and escaped identifiers are not further processed; they are returned exactly as expressed in the input SQL. By default, the tokenizer will ignore unterminated comments and strings, and stop parsing at that point, producing no further tokens. You can set $parser- throw on bad syntax = true; to throw an exception of type iamcal\\SQLParserSyntaxException instead. Performance My test target is an 88K SQL file containing 114 tables from Glitch's main database. The first version, using php-sql-parser, took over 60 seconds just to lex the input. This was obvi","default_branch":null,"files":null,"tree":[],"storefront":"/r/iamcal","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/iamcal/SQLParser/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}