r/Basic • • 2h ago

DDGBasic: a BASIC dialect where SQLite is built in, so SQL statements are just statements

I’ve been working on a small BASIC interpreter for a while under the name DBBasic. I’ve just renamed it DDGBasic. The idea behind it is that SQL shouldn’t need a driver, a connection object, or a string-building layer. SQLite is part of the language, and host variables bind with :name

No cursor handling, no ? placeholders, and no string concatenation to build queries. Variables bind safely, so injection isn’t a concern for values.

Other things it has:

  • Data-centric from the start: LOAD for CSV/JSONL/Parquet with TRANSFORM and VALIDATE clauses, and FETCH for HTTP (GET/POST/PUT/PATCH/DELETE)

  • DuckDB support alongside SQLite, for analytical queries

  • User-defined functions with proper shadow scoping, and DIM for locals

  • String interpolation with ${} in backtick strings

  • Higher-order functions: MAP, FILTER, REDUCE, SORT WITH

  • 0-based arrays, + for numbers and & for string concatenation (no more accidental "1"+"2")

Why BASIC? Partly nostalgia. Mostly because BASIC’s “type it and it runs” feel is a good fit for quick data wrangling: loading a file, poking at it with SQL, and writing the result out. For that kind of one-off work it’s less ceremony than a Python script with sqlite3 and pandas.

Install: pip install ddgbasic

Site: https://github.com/ddgflorida/DDGBasic

basic

database engine sqlite 
REM Supports DuckDB also
create table t (n integer);

for i = 1 to 10
  insert into t values (:i);
next

for row in (select n, n*n as sq from t where n % 2 = 0)
  print row.n, row.sq
next
4 Upvotes

0 comments sorted by