<s> from django . db . backends import BaseDatabaseIntrospection <EOL> import cx_Oracle <EOL> import re <EOL> foreign_key_re = re . compile ( r"<STR_LIT>" ) <EOL> class DatabaseIntrospection ( BaseDatabaseIntrospection ) : <EOL> data_types_reverse = { <EOL> cx_Oracle . CLOB : '<STR_LIT>' , <EOL> cx_Oracle . DATETIME : '<STR_LIT>' , <EOL> cx_Oracle . FIXED_CHAR : '<STR_LIT>' , <EOL> cx_Oracle . NCLOB : '<STR_LIT>' , <EOL> cx_Oracle . NUMBER : '<STR_LIT>' , <EOL> cx_Oracle . STRING : '<STR_LIT>' , <EOL> cx_Oracle . TIMESTAMP : '<STR_LIT>' , <EOL> } <EOL> try : <EOL> data_types_reverse [ cx_Oracle . NATIVE_FLOAT ] = '<STR_LIT>' <EOL> except AttributeError : <EOL> pass <EOL> try : <EOL> data_types_reverse [ cx_Oracle . UNICODE ] = '<STR_LIT>' <EOL> except AttributeError : <EOL> pass <EOL> def get_field_type ( self , data_type , description ) : <EOL> if data_type == cx_Oracle . NUMBER and description [ <NUM_LIT:5> ] == <NUM_LIT:0> : <EOL> if description [ <NUM_LIT:4> ] > <NUM_LIT:11> : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return super ( DatabaseIntrospection , self ) . get_field_type ( <EOL> data_type , description ) <EOL> def get_table_list ( self , cursor ) : <EOL> "<STR_LIT>" <EOL> cursor . execute ( "<STR_LIT>" ) <EOL> return [ row [ <NUM_LIT:0> ] . lower ( ) for row in cursor . fetchall ( ) ] <EOL> def get_table_description ( self , cursor , table_name ) : <EOL> "<STR_LIT>" <EOL> cursor . execute ( "<STR_LIT>" % self . connection . ops . quote_name ( table_name ) ) <EOL> description = [ ] <EOL> for desc in cursor . description : <EOL> description . append ( ( desc [ <NUM_LIT:0> ] . lower ( ) , ) + desc [ <NUM_LIT:1> : ] ) <EOL> return description <EOL> def table_name_converter ( self , name ) : <EOL> "<STR_LIT>" <EOL> return name . lower ( ) <EOL> def _name_to_index ( self , cursor , table_name ) : <EOL> """<STR_LIT>""" <EOL> return dict ( [ ( d [ <NUM_LIT:0> ] , i ) for i , d in enumerate ( self . get_table_description ( cursor , table_name ) ) ] ) <EOL> def get_relations ( self , cursor , table_name ) : <EOL> """<STR_LIT>""" <EOL> cursor . execute ( """<STR_LIT>""" , [ table_name , table_name , table_name ] ) <EOL> relations = { } <EOL> for row in cursor . fetchall ( ) : <EOL> relations [ row [ <NUM_LIT:0> ] ] = ( row [ <NUM_LIT:2> ] , row [ <NUM_LIT:1> ] ) <EOL> return relations <EOL> def get_indexes ( self , cursor , table_name ) : <EOL> """<STR_LIT>""" <EOL> sql = """<STR_LIT>""" <EOL> cursor . execute ( sql , [ table_name ] ) <EOL> indexes = { } <EOL> for row in cursor . fetchall ( ) : <EOL> indexes [ row [ <NUM_LIT:0> ] ] = { '<STR_LIT:primary_key>' : row [ <NUM_LIT:1> ] , '<STR_LIT>' : row [ <NUM_LIT:2> ] } <EOL> return indexes </s>
