Skip to main content

Overview

FreeTAKServer uses SQLAlchemy ORM for database operations with support for SQLite and MySQL. The database stores:
  • User information and authentication
  • Cursor on Target (CoT) events
  • Data packages
  • Video streams
  • Emergency notifications
  • Federation configurations
  • ExCheck checklists
  • API users and access logs

Database Configuration

Database settings are managed through the DatabaseConfiguration class located in FreeTAKServer/core/configuration/DatabaseConfiguration.py.

Database Type

string
default:"SQLite"
Database engine to use. Supported values: SQLite, MySQLEnvironment variable: FTS_DATABASE_TYPEYAML: System.FTS_DATABASE_TYPE

Database Path

string
default:"/opt/fts/FTSDataBase.db"
Path to the database file (SQLite) or connection details (MySQL)Environment variable: FTS_DB_PATHYAML: Filesystem.FTS_DB_PATH

CoT Database Storage

boolean
default:"true"
Whether to save Cursor on Target (CoT) messages to the databaseEnvironment variable: FTS_COT_TO_DBYAML: Filesystem.FTS_COT_TO_DB

Connection Strings

The DatabaseConfiguration class automatically generates SQLAlchemy connection strings based on the database type.

SQLite Configuration

YAML Configuration:
Environment Variables:

MySQL Configuration

YAML Configuration:
Environment Variables:
Connection String Format:
Example:

Database Controller

The DatabaseController class (FreeTAKServer/core/persistence/DatabaseController.py) provides the main interface for database operations.

Initialization

The controller automatically:
  1. Creates the SQLAlchemy engine with the configured connection string
  2. Creates a session maker
  3. Creates an active session
  4. Initializes table controllers for each data type
  5. Creates all database tables if they don’t exist
  6. Creates a default admin user on first run

Default Admin User

On first initialization, a default system user is created:
Change the default admin credentials immediately after installation for security.

Database Tables

FreeTAKServer creates and manages the following database tables:

User Tables

  • User: TAK client users and their CoT information
  • SystemUser: System administrators and API users
  • APIUsers: REST API user authentication

Event Tables

  • Event: CoT events (when SaveCoTToDB is enabled)
  • Archive: Archived CoT data
  • Chat: Chat messages
  • Emergency: Emergency notifications
  • ActiveEmergencys: Currently active emergencies

Data Tables

  • DataPackage: Uploaded data packages
  • VideoStream: Video stream configurations
  • _Video: Video metadata

Checklist Tables

  • ExCheck: ExCheck templates
  • ExCheckChecklist: ExCheck checklist instances
  • ExCheckKeywords: Keywords for ExCheck
  • ExCheckData: ExCheck data entries

Federation Tables

  • Federations: Federation server configurations
  • ActiveFederations: Currently active federation connections

Support Tables

  • _Group: CoT group information
  • Color: CoT color information
  • Contact: Contact details
  • Dest: Destination information
  • Link: CoT links
  • Marti: Marti-specific data
  • Precisionlocation: High-precision location data
  • Remarks: CoT remarks
  • Serverdestination: Server destination routing
  • Status: Status information
  • Summary: CoT summaries
  • Takv: TAK version information
  • Track: Tracking data
  • Uid: Unique identifiers
  • Usericon: User icon data

Logging Tables

  • APICalls: REST API access logs

Database Operations

The DatabaseController provides CRUD operations for all tables.

Create Operations

Query Operations

Update Operations

Delete Operations

Session Management

The DatabaseController manages SQLAlchemy sessions automatically.

Session Creation

Manual Session Creation

Shutdown Connection

CoT Event Storage

When SaveCoTToDB is enabled, all CoT events are stored in the database.

Creating CoT Events

Querying CoT Events

Disabling CoT Storage

To reduce database size and improve performance, you can disable CoT storage:
Disabling CoT storage reduces database growth but prevents historical event queries and replay functionality.

Database Migrations

FreeTAKServer uses SQLAlchemy’s metadata system for automatic table creation.

Automatic Migration

On startup, the database controller automatically:
  1. Connects to the database
  2. Checks for the SystemUser table
  3. If tables don’t exist, creates all tables from the Base metadata
  4. Creates default admin user if it’s a new installation

Manual Table Creation

Database Backup

SQLite Backup

MySQL Backup

Performance Optimization

SQLite Optimization

Disable CoT Storage (if not needed):
Use WAL Mode (Write-Ahead Logging):

MySQL Optimization

Connection Pooling:
Indexes (automatically created by SQLAlchemy for primary and foreign keys)

Database Troubleshooting

Common Issues

Database locked (SQLite):
  • Ensure only one FreeTAKServer instance is running
  • Check for stuck processes: lsof /opt/fts/FTSDataBase.db
  • Enable WAL mode for better concurrency
Connection refused (MySQL):
  • Verify MySQL service is running: systemctl status mysql
  • Check connection string format
  • Verify user permissions: GRANT ALL ON freetakserver.* TO 'ftsuser'@'localhost'
Table doesn’t exist:
  • Delete database file and restart (SQLite)
  • Run manual table creation script
  • Check database permissions
Slow queries:
  • Disable CoT storage if not needed
  • Increase MainLoopDelay to reduce database writes
  • Use MySQL instead of SQLite for large deployments

Example Configurations

Development (SQLite)

Production (SQLite)

Production (MySQL)

Best Practices

Always backup your database before upgrading FreeTAKServer or making configuration changes.
For deployments with more than 50 concurrent clients, consider using MySQL instead of SQLite for better concurrent write performance.
  • Regular database backups (automated daily backups recommended)
  • Monitor database size and implement retention policies
  • Use MySQL for production deployments with many clients
  • Disable CoT storage if historical event data is not needed
  • Implement database backup automation
  • Set appropriate filesystem permissions on database files
  • Use connection pooling for MySQL deployments
  • Monitor database performance and adjust MainLoopDelay accordingly
  • Keep database files on fast storage (SSD recommended)
  • Regularly vacuum SQLite databases to reclaim space