neosqlite.collection.schema_utils module

Schema inspection and modification utilities for NeoSQLite.

This module provides common functionality for inspecting and modifying database schemas, avoiding code duplication across multiple modules.

neosqlite.collection.schema_utils.get_table_columns(db_connection: Any, table_name: str) set[str][source]

Get set of column names for a table.

Parameters:
  • db_connection – SQLite database connection

  • table_name – Name of the table to inspect

Returns:

Set of column names

neosqlite.collection.schema_utils.column_exists(db_connection: Any, table_name: str, column_name: str) bool[source]

Check if column exists in table.

Parameters:
  • db_connection – SQLite database connection

  • table_name – Name of the table

  • column_name – Name of the column to check

Returns:

True if column exists, False otherwise

neosqlite.collection.schema_utils.add_column_if_not_exists(db_connection: Any, table_name: str, column_name: str, column_type: str = 'TEXT') bool[source]

Add column if it doesn’t exist.

Parameters:
  • db_connection – SQLite database connection

  • table_name – Name of the table

  • column_name – Name of the column to add

  • column_type – SQL type for the new column (default: TEXT)

Returns:

True if column was added, False if it already existed

neosqlite.collection.schema_utils.create_unique_index_on_id(db_connection: Any, table_name: str) bool[source]

Create a unique index on the _id column if it doesn’t exist.

Parameters:
  • db_connection – SQLite database connection

  • table_name – Name of the table

Returns:

True if index was created successfully, False otherwise

neosqlite.collection.schema_utils.get_table_info(db_connection: Any, table_name: str) dict[str, Any][source]

Get detailed information about a table.

Parameters:
  • db_connection – SQLite database connection

  • table_name – Name of the table to inspect

Returns:

Dictionary with table information including columns and indexes