#NEWLINE# def get_primary_key_column( self , cursor , table_name ) : #NEWLINE# #INDENT# '\n        Get the column name of the primary key for the given table.\n        ' #NEWLINE# cursor . execute ( 'SELECT sql FROM sqlite_master WHERE tbl_name = %s AND type = %s' , [ table_name , 'table' ] ) #NEWLINE# row = cursor . fetchone ( ) #NEWLINE# if ( row is None ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Table %s does not exist' % table_name ) ) #NEWLINE# #UNINDENT# results = row [ 0 ] . strip ( ) #NEWLINE# results = results [ ( results . index ( '(' ) + 1 ) : results . rindex ( ')' ) ] #NEWLINE# for field_desc in results . split ( ',' ) : #NEWLINE# #INDENT# field_desc = field_desc . strip ( ) #NEWLINE# m = re . search ( '"(.*)".*PRIMARY KEY( AUTOINCREMENT)?$' , field_desc ) #NEWLINE# if m : #NEWLINE# #INDENT# return m . groups ( ) [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# return None