The Vault (Databases)

BigC offers two ways to store structured data: Native DBIG (Simple Key-Value) and Universal SQL (SQLite).


1. Native DBIG (.dbig)

A simple, file-based Key-Value store. No setup required.

Saving Data

Value: dbig set "[Key]" as "[Value]" @"[File.dbig]" List: dbig set "[Key]" as {[ListVar]} list @"[File.dbig]"

dbig set "Username" as "BigCoder" @"game.dbig"

Loading Data

Value: dbig get "[Key]" @"[File.dbig]" & set as {[Variable]} List: dbig get "[Key]" @"[File.dbig]" & set as list {[ListVar]}

dbig get "Username" @"game.dbig" & set as {User}
print "Welcome back, $User"

2. Universal SQL (SQLite)

Unlock the full power of SQL. Requires use sql at the start of your file.

Unlock: use sql

Running Commands (Action)

Use run sql for commands that do not return data (CREATE, INSERT, UPDATE, DELETE). Syntax: run sql "[Query]" on "[DatabaseFile]"

run sql "CREATE TABLE users (name TEXT)" on "app.db"
run sql "INSERT INTO users (name) VALUES ('Alice')" on "app.db"

Note: You can use String Interpolation ($Var) inside the query string.

Fetching Data (Query)

Use get sql to retrieve data. It always returns a List of values (usually from the first column selected). Syntax: get sql "[Query]" on "[DatabaseFile]" & set as list {[ListVar]}

get sql "SELECT name FROM users" on "app.db" & set as list {Names}
get count of {Names} & set as {Count}
print "Found $Count users."