#NEWLINE# def GetFirstPrimaryKeyValue( self , optional_where = '1' ) : #NEWLINE# #INDENT# 'Return the PRIMARY KEY for the first row of the table.\n\n    Return the PRIMARY KEY row value for the first row in the table if\n    optional_where is undefined.\n\n    If optional_where is specified, return the first PRIMARY KEY row value\n    from the corresponding result set.\n\n    Args:\n      optional_where: (str) if unspecified returns the first row of the table.\n        If specified, return the first PRIMARY KEY row within the result set.\n    Returns:\n      The PRIMARY KEY values for the start of our range.\n        {col_name: value, ...}\n      Returns None if no records found in table.\n    ' #NEWLINE# attrs = self . _attrs . copy ( ) #NEWLINE# attrs [ 'select' ] = self . _PrimaryKeyForSelect ( ) #NEWLINE# attrs [ 'optional_where' ] = optional_where #NEWLINE# sql = 'SELECT %(select)s FROM %(db)s.%(table)s FORCE INDEX (PRIMARY) WHERE %(optional_where)s LIMIT 1' #NEWLINE# res = self . _dbh . ExecuteOrDie ( ( sql % attrs ) ) #NEWLINE# if res : #NEWLINE# #INDENT# return res [ 0 ]