Files
data_pipeline/clickhouse_task/delete_task.py
T
Ankit Malik 7fbbffec65 first commit
2026-06-12 10:54:00 +05:30

31 lines
711 B
Python

from db_con.connection import *
from log import *
def truncate_table(client, table_name: str) -> None:
"""
Truncate a ClickHouse table.
"""
query = f"TRUNCATE TABLE {table_name}"
print(f"Truncating table: {table_name}")
client.command(query)
log.info(f"Table {table_name} truncated successfully.")
def delete_rows(client, table_name: str, condition: str) -> None:
"""
Delete rows from a ClickHouse table based on a condition.
"""
query = f"""
ALTER TABLE {table_name}
DELETE WHERE {condition}
"""
print(f"Deleting rows from {table_name} where {condition}")
client.command(query)
log.info("Delete command submitted successfully.")