The Python database management tool for LandSandBoat — updating, migrating, backing up, and managing the game database.
tools/dbtool.py is the primary database management utility. It handles initial database setup, incremental updates, data migrations, backups, and several maintenance tasks.
# Python 3 and pip are requiredpython3 --version# Install dependenciespip install -r tools/requirements.txt
Required Python packages: mariadb, gitpython, pyyaml, colorama, zmq.The tool also requires mysql (or mariadb) CLI tools to be available on PATH, or configured via tools/config.yaml.
Update the database to match the current repository state.
# Express update — only imports SQL files changed since last known versionpython tools/dbtool.py update# Full update — re-imports all SQL filespython tools/dbtool.py update full
What it does:
Optionally creates a backup (controlled by auto_backup in config.yaml)
Imports any missing protected tables (first-time setup only)
Imports all changed .sql files from sql/
Runs any pending data migrations
Updates the version hash stored in config.yaml
Protected tables (player data: characters, accounts, inventory, etc.) are never overwritten by an update. Only missing protected tables are imported on first run.
Check and run any pending Python data migrations without doing a full SQL import.
python tools/dbtool.py migrate
Migrations live in tools/migrations/ as individual Python modules. Each migration checks whether it needs to run and applies schema or data transformations that cannot be expressed as a plain SQL file replacement.
Create a database backup in sql/backups/.
# Full database backuppython tools/dbtool.py backup# Lite backup — protected (player data) tables onlypython tools/dbtool.py backup lite
Backup filenames include the database name, timestamp, and (for full backups) the git version hash:
xidb-20241201-143022-a1b2.sql
Create and fully populate a new database. Requires the database name as a confirmation argument:
python tools/dbtool.py setup xidb
Creates the database with utf8mb4 character set and imports all SQL files.
Export live database values back into the SQL source files.
# Dump a single tablepython tools/dbtool.py dump mob_spawn_points# Dump all non-protected tablespython tools/dbtool.py dump
This is used by developers to capture database changes made directly in MariaDB and write them back to the repository SQL files.
Dbtool stores its own configuration in tools/config.yaml. This file is created automatically on first run.
- mysql_bin: "/usr/bin/" # Path to MySQL/MariaDB CLI bin directory- auto_backup: 0 # 0=off, 1=full auto backup, 2=lite auto backup- auto_update_client: true # Automatically update CLIENT_VER in login.lua- db_ver: "a1b2" # Git hash of the last successful update
Key
Type
Description
mysql_bin
string
Path to the directory containing mysql/mysqldump executables
auto_backup
int
0 = no auto backup, 1 = full backup before CLI update, 2 = lite backup
auto_update_client
bool
Update CLIENT_VER in settings/login.lua when running update
db_ver
string
4-character short git hash of the last applied update, used for express mode
The interactive menu’s l option launches all four server processes using zone IP and port settings read from the zone_settings database table:
# What it runs:xi_connect --log log/connect-server.logxi_search --log log/search-server.logxi_world --log log/world-server.logxi_map --log log/map-server-54230.log --ip <zoneip> --port 54230# (one xi_map per distinct port in zone_settings)
Before launching a public server, use option 2 in the Maintenance Tasks menu (or dbtool.py directly) to set the correct external IP address in zone_settings.