dissect.sql.utils

Module Contents

Functions

split_sql_list

Split a string on comma's (`,') while ignoring any comma's contained

parse_table_columns_constraints

Parse SQL CREATE TABLE statements and return the primary key, column

split_column_def

Splits the column definition to name and constraint.

get_primary_key_from_constraint

Finds a primary key from sql string.

dissect.sql.utils.split_sql_list(sql: str) Iterator[str]

Split a string on comma’s (`,’) while ignoring any comma’s contained within an arbitrary level of nested braces (`( )’)

dissect.sql.utils.parse_table_columns_constraints(sql: str) tuple[str | None, list[str], list[str]]

Parse SQL CREATE TABLE statements and return the primary key, column definitions and table constraints.

The retrun value is a tuple of:

(primary_key, [column, …], [table_constraint, …]) where column is a tuple of: (column_name, column_type_constraint)

dissect.sql.utils.split_column_def(sql: str, column_def: str) Tuple[str, str]

Splits the column definition to name and constraint.

dissect.sql.utils.get_primary_key_from_constraint(column_type_constraint: str, column_def: str, sql: str) str | None

Finds a primary key from sql string.