database_open
Open a database connection (SQLite, PostgreSQL, MySQL/MariaDB). Can use a DSN string, a .env file, or a settings dictionary.
database_open(
[dsn],
[dotfile],
[dotdsn=DATABASE_URL],
[timeout=5000],
[settings]
)
Open a database connection (SQLite, PostgreSQL, MySQL/MariaDB). Can use a DSN string, a .env file, or a settings dictionary.
Syntaxe
// Via DSN
var db = database_open("sqlite://local.sqlite");
// Via Settings dictionary
var db = database_open(settings={driver: "mysql", user: "root", password: "...", database: "test"});
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
dsn | - | - | Database connection string | |
dotfile | - | - | Path to .env file | |
dotdsn | - | DATABASE_URL | Environment variable name containing the DSN | |
timeout | - | 5000 | Connection timeout in ms | |
settings | - | - | Connection settings as a dictionary (driver, user, password, host, port, database) |