fix¶
sqlite-clean fixes - Applying fixes for SQLite databases.
- sqlite_clean.fix.clean_like_nulls(sql_engine: Union[str, Engine], dest_path: Optional[str] = None, table_name: Optional[str] = None, column_name: Optional[str] = None, inplace: bool = True) Engine ¶
Updates column values from ‘nan’ to NULL, performing necessary database schema updates where necessary.
- sql_engine: str | sqlalchemy.engine.base.Engine
filename of the SQLite database or existing sqlalchemy engine dest_path: str the destination of the updated database with nullable columns, by default None
- 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
- inplace: bool
whether to replace the source sql database, by default True
- sqlalchemy.engine.base.Engine
A SQLAlchemy engine for the database
- sqlite_clean.fix.update_columns_to_nullable(sql_engine: Union[str, Engine], dest_path: Optional[str] = None, table_name: Optional[str] = None, inplace: bool = True) Engine ¶
Update SQLite database columns to nullable where appropriate. Use a backup database to avoid data corruption issues and roughly follow 9-step procedure outlined by SQLite docs here: https://www.sqlite.org/lang_altertable.html#making_other_kinds_of_table_schema_changes
Special notes: - We take advantage of Python >= 3.7 sqlite3 api backup capabilities to keep to a standard implementation for backup portion of this work.
- sql_engine: str | sqlalchemy.engine.base.Engine
filename of the SQLite database or existing sqlalchemy engine
- dest_path: str
the destination of the updated database with nullable columns, by default None
- table_name: str
optional specific table name to update within database, by default None
- inplace: bool
whether to replace the source sql database, by default True
- sqlalchemy.engine.base.Engine
A SQLAlchemy engine for the changed database
- sqlite_clean.fix.update_values_like_null_to_null(sql_engine: Union[str, Engine], table_name: Optional[str] = None, column_name: Optional[str] = None, like_nulls: Tuple[str, ...] = ('null', 'none', 'nan')) Engine ¶
Updates column values from ‘nan’ to NULL where possible.
- 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
- like_nulls: List[str]
tuple strings which may represent null values
- sqlalchemy.engine.base.Engine
A SQLAlchemy engine for the changed database