Query
The Query view gives you direct SQL access to your financial data via DuckDB.
Press Cmd+Enter to run a query. Click Schema to see available tables and columns.
Example Queries
Section titled “Example Queries”Spending by Tag
Section titled “Spending by Tag”SELECT tag, SUM(amount) as totalFROM ( SELECT unnest(tags) as tag, amount FROM transactions WHERE amount < 0)GROUP BY tagORDER BY totalMonthly Spending
Section titled “Monthly Spending”SELECT strftime('%Y-%m', transaction_date) as month, SUM(amount) as totalFROM transactionsWHERE amount < 0GROUP BY monthORDER BY month DESCLIMIT 12Untagged Transactions
Section titled “Untagged Transactions”SELECT transaction_date, description, amountFROM transactionsWHERE CAST(tags AS VARCHAR) = '[]'ORDER BY transaction_date DESCSchema Reference
Section titled “Schema Reference”For the complete database schema including all tables and columns, see Database Schema.
- Use
unnest(tags)to expand tag arrays for grouping - Use
ILIKE '%term%'for case-insensitive text matching - Date filtering:
transaction_date >= CURRENT_DATE - INTERVAL '30 days'
Write Mode
Section titled “Write Mode”By default, only SELECT queries are allowed. Enable Write mode to run INSERT, UPDATE, or DELETE queries. Treeline will offer to create a backup first.
In the CLI, use tl query --allow-writes to enable write operations.
Write queries cannot be undone.