OVERVIEW
Monorepo/Foundation Libraries/libs/sql
v0.1.0 • ActiveSource Code
libs/sql/

libs/sql

SQLite3 Database Driver & Fluent Query Builder

Embedded relational database connectivity for Kale applications. Provides safe wrappers for SQLite3 connection handles, parameterized prepared statements with positional and named bindings, transaction rollbacks, and a fluent query builder.

Database EngineSQLite 3.45+
Query BuilderType-Safe Fluent AST
TransactionsACID with Auto-Rollback
MilestoneM10 Complete
libs/sql
Protocol & Wire Format Architecture
Zero-Heap Allocation Primitives
Deterministic Memory
Buffer allocations are bound to caller lifecycle with zero heap fragmentation
RFC Wire Conformance
Strict binary packet layout and protocol compliance written in pure Kale
Monorepo Integration
Instantly consumable by Compiler, Editor, and Bare-Metal targets
Architecture Contract

High-Throughput Systems Foundation

Engineered to maximize CPU instruction pipelining and data cache locality. Every algorithm avoids heap pointer indirection wherever contiguous stack or arena buffers can be employed.

Verification: 138/138 Regression Suite Pass
Signed commit governance • Strict type safety
Systems Foundation
db_demo.kl
kale
import "libs/sql/db.kl" as sql;

fn main() -> int32 {
    let db: sql.Database = sql.open("data/kale.db");
    sql.exec(&db, "CREATE TABLE IF NOT EXISTS projects (id INTEGER PRIMARY KEY, name TEXT, tier TEXT);");
    
    let stmt: sql.Statement = sql.prepare(&db, "INSERT INTO projects (name, tier) VALUES (?, ?);");
    sql.bind_text(&stmt, 1, "libs/render");
    sql.bind_text(&stmt, 2, "Foundation");
    sql.step(&stmt);
    sql.finalize(&stmt);
    
    sql.close(&db);
    return 0;
}
Compilation & Linker Directives

Deterministic command-line invocations to build, link native dynamic dependencies, and run automated regression tests:

$kale build tests/test_sql.kl -o bin/test_sql.exe -lsqlite3
$./bin/test_sql.exe
Monorepo Governance

GPG Key 1B917D4779A6102E • Continuous integration with automated symbol verification.

Architectural Capabilities
Prepared Statement Cache

Zero-allocation statement execution with parameterized value binding to prevent SQL injection.

Fluent Query Builder

Construct SELECT, INSERT, UPDATE, and DELETE queries through a type-checked builder interface.

Streaming Result Cursor

Iterate across millions of database rows with minimal memory footprint.