Connection Settings
The DB_Sqlite sample runs on a single SQLite connection. The connection definition lives in two places — one is the source of truth, the other is a synchronized copy.
| Location | Role |
|---|---|
DB_Sqlite.xmp → "DatabaseOption" block | SoT — packaged when the project is built/deployed |
XDatabase/connections.json | The mirror DB Studio reads — auto-updated when you edit through the tool |
In scripts (Data.xms etc.), the connection is reached with a single line: DB["local"].
The Sample's Actual Settings
Excerpt of the DatabaseOption block from DB_Sqlite.xmp:
"DatabaseOption": {
"Connections": [
{
"Name": "local",
"Type": "sqlite",
"Path": "XDatabase/LocalDB.db",
"Server": "",
"Database": "",
"User": "",
"PasswordEnc": "",
"ConnectionTimeout": 15,
"CommandTimeout": 30,
"PingIntervalSec": 10,
"ReconnectRetries": 3,
"Description": "test db"
}
],
"BackupFolder": "XDatabase/Backup",
"AutoBackupEnabled": false,
"AutoBackupIntervalHours": 24,
"BackupKeepLast": 30,
"JournalMode": "WAL"
}connections.json carries the same content. Editing through the DB Studio GUI keeps both files in sync.
Field Reference
Connection itself
| Key | Value / Meaning |
|---|---|
| Name | "local" — the identifier scripts use as DB["local"]. Lowercase recommended |
| Type | "sqlite" (alt: "mssql") |
| Path | "XDatabase/LocalDB.db" — SQLite file (relative to project root) |
| Server / Database / User / PasswordEnc | Empty for SQLite. Used only by MSSQL |
| ConnectionTimeout | Connect-attempt timeout (seconds). Default 15 |
| CommandTimeout | Single-SQL execution timeout (seconds). Default 30 |
| PingIntervalSec | Liveness check period (seconds). Default 10. Mostly irrelevant for SQLite |
| ReconnectRetries | Auto-reconnect attempts on disconnection. Default 3 |
| Description | Human-readable description. Shown in UI; no behavioral effect |
Options (outside the Connections array)
| Key | Meaning |
|---|---|
| BackupFolder | Folder for auto/manual backup files. Covered in Ch. 9 |
| AutoBackupEnabled | If true, periodic backups run |
| AutoBackupIntervalHours | Backup period (hours). Default 24 |
| BackupKeepLast | Number of backups to keep — extras pruned automatically |
| JournalMode | SQLite journal mode. Recommended "WAL". Covered in Ch. 9 |
SQLite vs. MSSQL — A Single Table
| Item | SQLite | MSSQL |
|---|---|---|
Type | "sqlite" | "mssql" |
| Required keys | Path | Server, Database, User, PasswordEnc |
| Notes | Self-contained single file, simple deploy | External server required, strong concurrent access |
The same script code (DB[...].RunSqlSelect(...)) works against either engine.
Two Ways to Register a New Connection
A. DB Studio (recommended)
Solution Explorer
└── Data Editor Pages
└── Database
└── Database Connections[+ Add] → fill in the fields from the table above and save. Both connections.json and the DatabaseOption block in .xmp are updated together.
B. Direct edit
You can open DB_Sqlite.xmp or XDatabase/connections.json in a text editor and add an object to the Connections array. Update both files together — otherwise different tools may show different information.
Next Chapter
Once the connection is in place, next is creating the table. The sample uses a single table order_history for all demonstrations.