SQLSegmenter#
- class langchain_community.document_loaders.parsers.language.sql.SQLSegmenter(code: str)[source]#
Code segmenter for SQL. This class uses Tree-sitter to segment SQL code into its constituent statements (e.g., SELECT, CREATE TABLE). It also provides functionality to extract these statements and simplify the code into commented descriptions.
Methods
__init__
(code)Extract SQL statements from the code.
Return the Tree-sitter query for SQL segmentation.
Return the SQL language grammar for Tree-sitter.
is_valid
()make_line_comment
(text)Create a line comment in SQL style.
Simplify the extracted SQL code into comments.
- Parameters:
code (str)
- __init__(code: str)#
- Parameters:
code (str)
- extract_functions_classes() list[str] [source]#
Extract SQL statements from the code. Ensures that all SQL statements end with a semicolon for consistency.
- Return type:
list[str]
- get_parser() Parser #
- Return type:
Parser
- is_valid() bool #
- Return type:
bool