Expand description

SQL parser

This is a simple SQL parser written in Rust using the pest library. The parser supports parsing CREATE TABLE statements with column definitions.

Example

extern crate yehorbolt_sql_parser;
use yehorbolt_sql_parser::parse_sql;

fn main() {
   let table = "CREATE TABLE financial_report
   {
       id INT,
       currency_name TEXT,
       is_usable BOOL
   }";
   let res = parse_sql(table);
   println!("Parsed: {:#?}", res);
}

In this example, the parse_sql function is used to parse the provided SQL CREATE TABLE statement, and the parsed result is printed using println! (with {:?}).

Structs

  • Represents information about a database column.
  • A variant of ColumnInfo with options for column name and column type.
  • Represents the structure of a SQL CREATE TABLE statement.
  • A variant of CreateTable with options for table name and column definitions.
  • SQL parser struct

Enums

Functions

  • This function parses a create table statement, extracting the table name, column names, and types to construct a CreateTable struct.
  • This function takes a SQL query as input and returns a parsed result.
  • This function, unwrap_column_info, recursively unwraps and extracts column information from a vector of optional ColumnInfoOption instances, returning a vector of ColumnInfo.