Skip to main content

SpatiaLiteIntrospection

This class provides database introspection capabilities specifically for SpatiaLite databases, extending standard database introspection to handle geographic data types. It retrieves detailed metadata for geometry columns, including coordinate dimensions, spatial reference system identifiers (SRIDs), and geometry types from the spatial metadata tables. Additionally, it identifies and incorporates spatial indexes into the table constraint information.

Attributes

AttributeTypeDescription
data_types_reverse[GeoFlexibleFieldLookupDict](geoflexiblefieldlookupdict.md?sid=django_contrib_gis_db_backends_spatialite_introspection_geoflexiblefieldlookupdict) = GeoFlexibleFieldLookupDict()A mapping of SpatiaLite-specific database column types to their corresponding Django field classes.

Methods


get_geometry_type()

@classmethod
def get_geometry_type(
table_name: string,
description: object
) - > tuple

Queries the geometry_columns metadata table to determine the specific Django field type and spatial parameters for a given column.

Parameters

NameTypeDescription
table_namestringThe name of the database table containing the geometry column.
descriptionobjectA column description object whose name attribute identifies the specific geometry field to inspect.

Returns

TypeDescription
tupleA tuple containing the Django field class name and a dictionary of keyword arguments such as SRID and dimensions.

get_constraints()

@classmethod
def get_constraints(
cursor: [Cursor](../../../../../../db/backends/postgresql/base/cursor.md?sid=django_db_backends_postgresql_base_cursor),
table_name: string
) - > dict

Retrieves standard table constraints and injects additional spatial index definitions found in the SpatiaLite metadata tables.

Parameters

NameTypeDescription
cursor[Cursor](../../../../../../db/backends/postgresql/base/cursor.md?sid=django_db_backends_postgresql_base_cursor)The active database cursor used to execute metadata queries.
table_namestringThe name of the table for which to retrieve constraint and index information.

Returns

TypeDescription
dictA dictionary mapping constraint names to their attributes, including newly identified spatial indexes.