def primarykeys(conn, table):
 rows = query(conn, "\n        SELECT c.column_name\n        FROM information_schema.table_constraints t\n        INNER JOIN information_schema.constraint_column_usage c\n                ON (t.CONSTRAINT_CATALOG =    c.CONSTRAINT_CATALOG\n            AND t.CONSTRAINT_NAME =   c.CONSTRAINT_NAME\n            AND t.CONSTRAINT_SCHEMA = c.CONSTRAINT_SCHEMA\n            AND t.TABLE_CATALOG =     c.TABLE_CATALOG\n            AND t.TABLE_NAME =        c.TABLE_NAME\n            AND t.TABLE_SCHEMA =      c.TABLE_SCHEMA)\n        WHERE t.table_name='%s'\n          AND t.constraint_type='PRIMARY KEY'\n        ;", table)
 return [row['column_name'] for row in rows]

def primarykeys ( conn , table ) : rows = query ( conn , "\n        SELECT c.column_name\n        FROM information_schema.table_constraints t\n        INNER JOIN information_schema.constraint_column_usage c\n                ON (t.CONSTRAINT_CATALOG =    c.CONSTRAINT_CATALOG\n            AND t.CONSTRAINT_NAME =   c.CONSTRAINT_NAME\n            AND t.CONSTRAINT_SCHEMA = c.CONSTRAINT_SCHEMA\n            AND t.TABLE_CATALOG =     c.TABLE_CATALOG\n            AND t.TABLE_NAME =        c.TABLE_NAME\n            AND t.TABLE_SCHEMA =      c.TABLE_SCHEMA)\n        WHERE t.table_name='%s'\n          AND t.constraint_type='PRIMARY KEY'\n        ;" , table ) return [ row [ 'column_name' ] for row in rows ]
find primary keys .