Run a single read-only SELECT query against the local finbridge database (ingested KR/US fundamentals, filings, daily prices). The statement must start with SELECT or WITH; multiple statements, PRAGMA, and any write/DDL keywords (INSERT/UPDATE/DELETE/DROP/ALTER/CREATE/ATTACH/...) are rejected. The query is executed as SELECT * FROM (<your sql>) LIMIT <limit> on a read-only connection.
The escape hatch for questions no dedicated tool answers — Japan, Taiwan and Europe are largely reachable only this way. Prefer screen_companies for ordinary fundamental screens (it handles per-market period and currency rules that a hand-written query will get wrong), and call get_db_schema first for the table shapes.
Args:
- sql: one SELECT (or WITH ... SELECT) statement. A single trailing ';' is tolerated.
- limit: max rows returned, 1-500 (default 50)
- response_format: 'markdown' (default, table) or 'json' (compact)
Returns: {columns: [name], rows: [[cell, ...]], row_count, truncated} — truncated=true means more rows matched than 'limit'.
Examples (v_financials / v_latest_annual views are the easiest entry points):
- Largest companies by latest annual revenue: "SELECT name, ticker, stock_code, fiscal_year, revenue FROM v_latest_annual ORDER BY revenue DESC LIMIT 10"
- Samsung Electronics annual trend: "SELECT fiscal_year, revenue, operating_income, net_income FROM v_financials WHERE stock_code = '005930' AND quarter = 0 ORDER BY fiscal_year DESC"
- KR vs US company counts: "SELECT source, COUNT(*) AS n FROM companies GROUP BY source"
- Recent Samsung Electronics closes: "SELECT date, close FROM prices_daily p JOIN companies c ON c.id = p.company_id WHERE c.stock_code = '005930' ORDER BY date DESC LIMIT 20" (prices_daily holds KR, US, TW; US history starts 2023-03-28)
Use when: custom aggregation/joins over ingested data that screen_companies cannot express. Don't use for anything that writes — it will be rejected — or for live quotes (use the live-source tools).
Errors: non-SELECT input, ';' inside, or forbidden keywords -> rejected with the reason; unknown table/column -> SQL error with a hint to call get_db_schema first.