package mantra.sql.orm
SQLiteAdapter
CLASS
public class
Embedded SQLite3 database driver. Implements DatabaseAdapter. Ideal for unit tests, embedded devices, and local caches. NEW in v0.2.0.
🏗️ Constructor Summary
Constructor Signature
def __init__(self, db_path: String)
⚙️ Method Summary
| Modifier & Return Type | Method Signature | Description |
|---|---|---|
Bool |
pub def connect() |
Opens SQLite database file or initializes in-memory database with ':memory:'. |
Bool |
pub def disconnect() |
Flushes pending transactions and releases database file lock. |
String |
pub def execute(sql: String) |
Executes SQL statement against SQLite engine and returns result. |
String |
pub def get_driver_name() |
Returns driver engine name and version ('SQLite 3'). |
🔍 Detailed Method Specifications
pub def connect() -> Bool
Opens SQLite database file or initializes in-memory database with
':memory:'.
pub def disconnect() -> Bool
Flushes pending transactions and releases database file lock.
pub def execute(sql: String) -> String
Executes SQL statement against SQLite engine and returns result.
pub def get_driver_name() -> String
Returns driver engine name and version ('SQLite 3').
💡 Example Usage
sqlite_example.mantra
let db = SQLiteAdapter(":memory:")
db.connect()
db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);")
db.execute("INSERT INTO users VALUES (1, 'Alice');")