Database Manual · Chapter 2

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.

LocationRole
DB_Sqlite.xmp → "DatabaseOption" blockSoT — packaged when the project is built/deployed
XDatabase/connections.jsonThe 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

KeyValue / 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 / PasswordEncEmpty for SQLite. Used only by MSSQL
ConnectionTimeoutConnect-attempt timeout (seconds). Default 15
CommandTimeoutSingle-SQL execution timeout (seconds). Default 30
PingIntervalSecLiveness check period (seconds). Default 10. Mostly irrelevant for SQLite
ReconnectRetriesAuto-reconnect attempts on disconnection. Default 3
DescriptionHuman-readable description. Shown in UI; no behavioral effect

Options (outside the Connections array)

KeyMeaning
BackupFolderFolder for auto/manual backup files. Covered in Ch. 9
AutoBackupEnabledIf true, periodic backups run
AutoBackupIntervalHoursBackup period (hours). Default 24
BackupKeepLastNumber of backups to keep — extras pruned automatically
JournalModeSQLite journal mode. Recommended "WAL". Covered in Ch. 9

SQLite vs. MSSQL — A Single Table

ItemSQLiteMSSQL
Type"sqlite""mssql"
Required keysPathServer, Database, User, PasswordEnc
NotesSelf-contained single file, simple deployExternal server required, strong concurrent access

The same script code (DB[...].RunSqlSelect(...)) works against either engine.

Two Ways to Register a New Connection

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.