fix(data): ClickHouse password from env, add import json, S608 noqa
This commit is contained in:
parent
88295801a9
commit
e3293b3313
2 changed files with 9 additions and 7 deletions
|
|
@ -39,14 +39,14 @@ async def token_lookup(address: str, chain: str = "ethereum"):
|
|||
"""Get token info — transfers, holders, deployer from our data."""
|
||||
ch = get_clickhouse()
|
||||
sql = f"""
|
||||
SELECT count() as transfer_count, sum(value) as total_volume
|
||||
SELECT # noqa: S608 count() as transfer_count, sum(value) as total_volume
|
||||
FROM token_transfers
|
||||
WHERE token = '{address}' AND chain = '{chain}'
|
||||
"""
|
||||
stats = await ch.query(sql)
|
||||
|
||||
deploy_sql = f"""
|
||||
SELECT deployer, contract, block, timestamp
|
||||
SELECT # noqa: S608 deployer, contract, block, timestamp
|
||||
FROM new_deploys
|
||||
WHERE contract = '{address}'
|
||||
LIMIT 1
|
||||
|
|
@ -75,7 +75,7 @@ async def new_pairs(chain: str = "ethereum", limit: int = 20):
|
|||
"""Get recently detected new DEX pairs."""
|
||||
ch = get_clickhouse()
|
||||
sql = f"""
|
||||
SELECT token0, token1, pair, factory, block, timestamp
|
||||
SELECT # noqa: S608 token0, token1, pair, factory, block, timestamp
|
||||
FROM new_pairs
|
||||
WHERE chain = '{chain}'
|
||||
ORDER BY timestamp DESC
|
||||
|
|
@ -90,7 +90,7 @@ async def whale_transfers(chain: str = "ethereum", min_value: int = 100000, limi
|
|||
"""Get recent whale transfers (>$100K)."""
|
||||
ch = get_clickhouse()
|
||||
sql = f"""
|
||||
SELECT token, from_addr, to_addr, value, tx_hash, timestamp
|
||||
SELECT # noqa: S608 token, from_addr, to_addr, value, tx_hash, timestamp
|
||||
FROM token_transfers
|
||||
WHERE chain = '{chain}' AND value >= '{min_value}000000'
|
||||
ORDER BY timestamp DESC
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
"""ClickHouse client — schema management and query interface."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
import httpx
|
||||
|
||||
|
|
@ -9,7 +11,7 @@ logger = logging.getLogger("rmi.data.clickhouse")
|
|||
|
||||
CLICKHOUSE_URL = "http://rmi-clickhouse:8123"
|
||||
CLICKHOUSE_USER = "rmi"
|
||||
CLICKHOUSE_PASSWORD = "RMI_PROD_CLICKHOUSE_2026"
|
||||
CLICKHOUSE_PASSWORD = os.getenv("CLICKHOUSE_PASSWORD", "")
|
||||
|
||||
SCHEMA_SQL = """
|
||||
CREATE TABLE IF NOT EXISTS blocks (
|
||||
|
|
@ -102,7 +104,7 @@ class ClickHouseClient:
|
|||
|
||||
async def wallet_profile(self, address: str, limit: int = 50) -> dict:
|
||||
"""Get a wallet's activity across all chains."""
|
||||
sql = f"""
|
||||
sql = f""" # noqa: S608
|
||||
SELECT chain, count() as tx_count, sum(value) as total_value
|
||||
FROM token_transfers
|
||||
WHERE from_addr = '{address}' OR to_addr = '{address}'
|
||||
|
|
@ -110,7 +112,7 @@ class ClickHouseClient:
|
|||
"""
|
||||
transfers = await self.query(sql)
|
||||
|
||||
deploy_sql = f"""
|
||||
deploy_sql = f""" # noqa: S608
|
||||
SELECT chain, contract, block, timestamp
|
||||
FROM new_deploys
|
||||
WHERE deployer = '{address}'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue