parameters: (connection, table)
return_statement: return 0
docstring: Reverse engineers the primary key for the given table.
docstring_summary: Reverse engineers the primary key for the given table.
docstring_tokens: Reverse engineers the primary key for the given table .
function: def reverseEngineerTablePK(connection, table):
      """Reverse engineers the primary key for the given table."""
  
      schema = table.owner
      catalog = schema.owner
      execute_query(connection, 'USE %s' % catalog.name)
      query ="""SELECT sc.name
  FROM sysobjects so JOIN syskeys sk ON so.id=sk.id
       JOIN syscolumns sc ON sc.id=sk.id AND sc.colid IN (sk.key1, sk.key2, sk.key3, sk.key4, sk.key5, sk.key6, sk.key7, sk.key8)
  WHERE so.uid=USER_ID(?) AND sk.id=OBJECT_ID(?) AND sk.type=1"""
  
      if len(table.columns) == 0:
          grt.send_error('Sybase reverseEngineerTablePK', "Reverse engineer of table's %s.%s primary key was attempted but the table has no columns attribute" % (schema.name, table.name) )
          return 1    # Table must have columns reverse engineered before we can rev eng its primary key
  
      pk_col_names = [ row[0] for row in execute_query(connection, query, schema.name, table.name) ]
  
      for pk_column in pk_col_names:
          column = find_object_with_name(table.columns, pk_column)
          if column:
              table.addPrimaryKeyColumn(column)
      return 0
function_tokens: def reverseEngineerTablePK ( connection , table ) : schema = table . owner catalog = schema . owner execute_query ( connection , 'USE %s' % catalog . name ) query = """SELECT sc.name
  FROM sysobjects so JOIN syskeys sk ON so.id=sk.id
       JOIN syscolumns sc ON sc.id=sk.id AND sc.colid IN (sk.key1, sk.key2, sk.key3, sk.key4, sk.key5, sk.key6, sk.key7, sk.key8)
  WHERE so.uid=USER_ID(?) AND sk.id=OBJECT_ID(?) AND sk.type=1""" if len ( table . columns ) == 0 : grt . send_error ( 'Sybase reverseEngineerTablePK' , "Reverse engineer of table's %s.%s primary key was attempted but the table has no columns attribute" % ( schema . name , table . name ) ) return 1 # Table must have columns reverse engineered before we can rev eng its primary key pk_col_names = [ row [ 0 ] for row in execute_query ( connection , query , schema . name , table . name ) ] for pk_column in pk_col_names : column = find_object_with_name ( table . columns , pk_column ) if column : table . addPrimaryKeyColumn ( column ) return 0