r/DuckDB • u/datadanno • 9d ago
Row by Row Processing in DuckDB
I built DDGBasic for exactly this gap — it's DuckDB with a procedural language wrapped around it.
SQL is great for set operations, but awkward for row-by-row rules, tiers, allocations, alerts, and file handling. In DDGBasic you can do:
basic
DATABASE ENGINE DUCKDB
DATABASE OPEN ":memory:"
CREATE TABLE domains AS
SELECT * FROM read_csv_auto('https://raw.githubusercontent.com/cisagov/dotgov-data/main/current-full.csv');
FOR row IN (SELECT State, COUNT(*) AS n FROM domains GROUP BY State ORDER BY n DESC LIMIT 5)
PRINT row.State, row.n
NEXT
Variables go into queries as bind variables (:name), you get IF, loops, user functions, transactions, and ON ERROR, plus LOAD CSV/JSON/Excel/Parquet with per-cell transforms and validation, and output to CSV, JSON, Excel, Parquet, or HTML. SQLite is the other engine if you want a transactional file DB instead.
1
u/Weekly-Werewolf4007 7d ago
The regional rules example looks like a good comparison case. I'd like to see it side by side with the same rules in SQL, with one timing for the query and another for the procedural step.