utils

sqlite-clean utility functions

sqlite_clean.utils.collect_columns(sql_engine: Union[str, Engine], table_name: Optional[str] = None, column_name: Optional[str] = None) list

Collect a list of columns from the given engine’s database using optional table or column level specification.

sql_engine: str | sqlalchemy.engine.base.Engine

filename of the SQLite database or existing sqlalchemy engine

table_name: str

optional specific table name to check within database, by default None

column_name: str

optional specific column name to check within database, by default None

list

Returns list, and if populated, contains tuples with values similar to the following. These may also be accessed by name similar to dictionaries, as they are SQLAlchemy Row objects. [(‘table_name’, ‘column_name’, ‘column_type’, ‘notnull’),…]

sqlite_clean.utils.engine_from_str(sql_engine: Union[str, Engine]) Engine

Helper function to create engine from a string or return the engine if it’s already been created.

sql_engine: str | sqlalchemy.engine.base.Engine

filename of the SQLite database or existing sqlalchemy engine

sqlalchemy.engine.base.Engine

A SQLAlchemy engine