#NEWLINE# def get_constraints( self , cursor , table_name ) : #NEWLINE# #INDENT# '\n        Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.\n        ' #NEWLINE# constraints = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# cursor . execute ( ( 'PRAGMA index_list(%s)' % self . connection . ops . quote_name ( table_name ) ) ) #NEWLINE# for row in cursor . fetchall ( ) : #NEWLINE# #INDENT# ( number , index , unique ) = row [ : 3 ] #NEWLINE# cursor . execute ( ( 'PRAGMA index_info(%s)' % self . connection . ops . quote_name ( index ) ) ) #NEWLINE# for ( index_rank , column_rank , column ) in cursor . fetchall ( ) : #NEWLINE# #INDENT# if ( index not in constraints ) : #NEWLINE# #INDENT# constraints [ index ] = { #NEWLINE# #INDENT# 'columns' : [ ] , #NEWLINE# 'primary_key' : False , #NEWLINE# 'unique' : bool ( unique ) , #NEWLINE# 'foreign_key' : False , #NEWLINE# 'check' : False , #NEWLINE# 'index' : True , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# constraints [ index ] [ 'columns' ] . append ( column ) #NEWLINE# #UNINDENT# #UNINDENT# pk_column = self . get_primary_key_column ( cursor , table_name ) #NEWLINE# if pk_column : #NEWLINE# #INDENT# constraints [ '__primary__' ] = { #NEWLINE# #INDENT# 'columns' : [ self ] , #NEWLINE# 'primary_key' : True , #NEWLINE# 'unique' : False , #NEWLINE# 'foreign_key' : False , #NEWLINE# 'check' : False , #NEWLINE# 'index' : False , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# return constraints