Expand description
SQL parsing utilities: statement splitting, FK extraction, source table detection.
Structs§
- Foreign
KeyInfo - Foreign key relationship from one column to another table/column.
Functions§
- detect_
source_ table - Detect whether a SQL query targets a single table and return that table name.
- detect_
statements - Split a SQL string into individual statements, respecting quoted strings and comments.
- extract_
identifier - Extract an identifier (possibly quoted with
"or`) from the start ofs. Returns (identifier,rest_of_string). - extract_
table_ name - Extract a single table name from the beginning of
text. Handles double-quoted and backtick-quoted names. Stops at whitespace,;, or end of string. - find_
from_ keyword - Find the position of the table name (the text after “FROM “) in
sql. Returns the byte offset intosqlof the text immediately after FROM and whitespace. - parse_
foreign_ keys - Parse foreign key relationships from a
CREATE TABLESQL statement. - strip_
comments - Remove SQL comments (both line
--and block/* */) from a SQL string. - unquote
- Remove surrounding quotes from a column name if present.