OxL Reference

method Db.open

Opens a database: postgres://… (libpq URI; ?schema=name selects/creates the schema, postgres: alone uses OXL_PG_DSN), sqlite:<path>, sqlite::memory: or builtin://<name> (the built-in replicated tables: SQLite per shard replica, Raft carries row changesets, D-4380; one shard is the file <name>.db in the data directory, --data-dir / OXL_DATA_DIR, default ./data; builtin://<name>?shards=N has N shards and @shard(by: .field) tables are routed by hash; atomic/transaction stay inside one shard, else CrossShardTx). A file is opened in WAL mode with a 5 s busy timeout.

Example:

oxl✓ checked in CI
use std.orm { Db }

fn main() io, db {
  let db = Db.open("sqlite::memory:")!
  print("opened")
  db.close()
}
Output
opened
pub(api) static fn open(url: str) -> Db | DbError  db

Since. 1.0.0-beta

Parameters

NameType
urlstr

Returns

Db

Errors

Effects

db

Defined in: std/orm/orm.oxl:287

See also