cycquery.ops.RenameΒΆ

class Rename(rename_map, check_exists=True)[source]ΒΆ

Bases: QueryOp

Rename some columns.

Parameters:
  • rename_map (Dict[str, str]) – Map from an existing column name to another name.

  • check_exists (bool) – Whether to check if all of the keys in the map exist as columns.

Examples

>>> Rename({"col1": "col1_new"})(table)

Methods

__call__(table)[source]ΒΆ

Process the table.

Parameters:

table (Union[Select, Subquery, Table, DBTable]) – Table on which to perform the operation.

Returns:

Processed table.

Return type:

sqlalchemy.sql.selectable.Subquery