<s> from django . contrib . gis . gdal import OGRGeomType <EOL> from django . db . backends . sqlite3 . introspection import DatabaseIntrospection , FlexibleFieldLookupDict <EOL> class GeoFlexibleFieldLookupDict ( FlexibleFieldLookupDict ) : <EOL> """<STR_LIT>""" <EOL> base_data_types_reverse = FlexibleFieldLookupDict . base_data_types_reverse . copy ( ) <EOL> base_data_types_reverse . update ( <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> class SpatiaLiteIntrospection ( DatabaseIntrospection ) : <EOL> data_types_reverse = GeoFlexibleFieldLookupDict ( ) <EOL> def get_geometry_type ( self , table_name , geo_col ) : <EOL> cursor = self . connection . cursor ( ) <EOL> try : <EOL> cursor . execute ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> ( table_name , geo_col ) ) <EOL> row = cursor . fetchone ( ) <EOL> if not row : <EOL> raise Exception ( '<STR_LIT>' % <EOL> ( table_name , geo_col ) ) <EOL> field_type = OGRGeomType ( row [ <NUM_LIT:2> ] ) . django <EOL> dim = row [ <NUM_LIT:0> ] <EOL> srid = row [ <NUM_LIT:1> ] <EOL> field_params = { } <EOL> if srid != <NUM_LIT> : <EOL> field_params [ '<STR_LIT>' ] = srid <EOL> if isinstance ( dim , basestring ) and '<STR_LIT>' in dim : <EOL> field_params [ '<STR_LIT>' ] = <NUM_LIT:3> <EOL> finally : <EOL> cursor . close ( ) <EOL> return field_type , field_params </s>
