Files
connect/examples/clear_test_databases.py
Joe SpadolaandGitHub 55dcd7db4c Replace pylint with ruff for linting and formatting (#703)
* migrate from pylint to ruff

* ruff format/lint switch over

* add formatting commit

* update changelog
2026-04-02 16:09:59 -07:00

23 lines
804 B
Python

#!/usr/bin/env python3 -u
import os
import clickhouse_connect
def main():
host = os.getenv("CLICKHOUSE_CONNECT_TEST_HOST", "localhost")
port = int(os.getenv("CLICKHOUSE_CONNECT_TEST_PORT", "8123"))
password = os.getenv("CLICKHOUSE_CONNECT_TEST_PASSWORD", "")
client = clickhouse_connect.get_client(host=host, port=port, password=password)
database_result = client.query("SELECT name FROM system.databases WHERE name ilike '%test%'").result_rows
for database_row in database_result:
database: str = database_row[0]
if database.startswith("dbt_clickhouse") or database.startswith("clickhouse_connect"):
print(f"DROPPING DATABASE `{database}`")
client.command(f"DROP DATABASE IF EXISTS {database}")
if __name__ == "__main__":
main()