|
| 1 | +--- |
| 2 | +title: "Query Backend" |
| 3 | +--- |
| 4 | + |
| 5 | +OpenTaco supports using a query backend to speed up the retrieval of objects from S3. By default SQLite will initialize, but other SQL databases can be configured if desired. If the backend is not SQLite you need to setup the database first before attempting to run statesman and populate the correct environment variables. |
| 6 | + |
| 7 | +## Configuration |
| 8 | + |
| 9 | +Set the backend type using: |
| 10 | + |
| 11 | +```bash |
| 12 | +TACO_QUERY_BACKEND=sqlite # Options: sqlite, postgres, mssql, mysql |
| 13 | +``` |
| 14 | + |
| 15 | +## SQLite (Default) |
| 16 | + |
| 17 | +SQLite is the default query backend and requires no external database server and no configuration. We expose settings for convenience but you should not need to configure SQLite in most circumstances. |
| 18 | + |
| 19 | +### Environment Variables |
| 20 | + |
| 21 | +```bash |
| 22 | +# Backend selection |
| 23 | +TACO_QUERY_BACKEND=sqlite |
| 24 | + |
| 25 | +# SQLite-specific configuration |
| 26 | +TACO_SQLITE_DB_PATH=./data/taco.db |
| 27 | +TACO_SQLITE_CACHE=shared |
| 28 | +TACO_SQLITE_BUSY_TIMEOUT=5s |
| 29 | +TACO_SQLITE_MAX_OPEN_CONNS=1 |
| 30 | +TACO_SQLITE_MAX_IDLE_CONNS=1 |
| 31 | +TACO_SQLITE_PRAGMA_JOURNAL_MODE=WAL |
| 32 | +TACO_SQLITE_PRAGMA_FOREIGN_KEYS=ON |
| 33 | +TACO_SQLITE_PRAGMA_BUSY_TIMEOUT=5000 |
| 34 | +``` |
| 35 | + |
| 36 | +### Defaults |
| 37 | +- **Path**: `./data/taco.db` |
| 38 | +- **Cache**: `shared` |
| 39 | +- **Busy Timeout**: `5s` |
| 40 | +- **Max Open Connections**: `1` |
| 41 | +- **Max Idle Connections**: `1` |
| 42 | +- **Journal Mode**: `WAL` |
| 43 | +- **Foreign Keys**: `ON` |
| 44 | + |
| 45 | +## PostgreSQL |
| 46 | + |
| 47 | +Use PostgreSQL for better concurrency and performance in production environments. |
| 48 | + |
| 49 | +### Environment Variables |
| 50 | + |
| 51 | +```bash |
| 52 | +# Backend selection |
| 53 | +TACO_QUERY_BACKEND=postgres |
| 54 | + |
| 55 | +# PostgreSQL-specific configuration |
| 56 | +TACO_POSTGRES_HOST=localhost |
| 57 | +TACO_POSTGRES_PORT=5432 |
| 58 | +TACO_POSTGRES_USER=postgres |
| 59 | +TACO_POSTGRES_PASSWORD=your_password |
| 60 | +TACO_POSTGRES_DBNAME=taco |
| 61 | +TACO_POSTGRES_SSLMODE=disable |
| 62 | +``` |
| 63 | + |
| 64 | +### Defaults |
| 65 | +- **Host**: `localhost` |
| 66 | +- **Port**: `5432` |
| 67 | +- **User**: `postgres` |
| 68 | +- **Database Name**: `taco` |
| 69 | +- **SSL Mode**: `disable` |
| 70 | + |
| 71 | +### Example Connection |
| 72 | + |
| 73 | +```bash |
| 74 | +export TACO_QUERY_BACKEND=postgres |
| 75 | +export TACO_POSTGRES_HOST=my-postgres-server.example.com |
| 76 | +export TACO_POSTGRES_PORT=5432 |
| 77 | +export TACO_POSTGRES_USER=taco_user |
| 78 | +export TACO_POSTGRES_PASSWORD=secure_password |
| 79 | +export TACO_POSTGRES_DBNAME=taco_prod |
| 80 | +export TACO_POSTGRES_SSLMODE=require |
| 81 | +``` |
| 82 | + |
| 83 | +## Microsoft SQL Server (MSSQL) |
| 84 | + |
| 85 | +Use MSSQL for enterprise environments with existing SQL Server infrastructure. |
| 86 | + |
| 87 | +### Environment Variables |
| 88 | + |
| 89 | +```bash |
| 90 | +# Backend selection |
| 91 | +TACO_QUERY_BACKEND=mssql |
| 92 | + |
| 93 | +# MSSQL-specific configuration |
| 94 | +TACO_MSSQL_HOST=localhost |
| 95 | +TACO_MSSQL_PORT=1433 |
| 96 | +TACO_MSSQL_USER=sa |
| 97 | +TACO_MSSQL_PASSWORD=your_password |
| 98 | +TACO_MSSQL_DBNAME=taco |
| 99 | +``` |
| 100 | + |
| 101 | +### Defaults |
| 102 | +- **Host**: `localhost` |
| 103 | +- **Port**: `1433` |
| 104 | +- **Database Name**: `taco` |
| 105 | + |
| 106 | +### Example Connection |
| 107 | + |
| 108 | +```bash |
| 109 | +export TACO_QUERY_BACKEND=mssql |
| 110 | +export TACO_MSSQL_HOST=sqlserver.example.com |
| 111 | +export TACO_MSSQL_PORT=1433 |
| 112 | +export TACO_MSSQL_USER=taco_admin |
| 113 | +export TACO_MSSQL_PASSWORD=secure_password |
| 114 | +export TACO_MSSQL_DBNAME=taco_db |
| 115 | +``` |
| 116 | + |
| 117 | +## MySQL |
| 118 | + |
| 119 | +Use MySQL for compatibility with existing MySQL infrastructure. |
| 120 | + |
| 121 | +As an example I used `CREATE DATABASE taco CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;` when testing the MySQL setup. |
| 122 | + |
| 123 | +### Environment Variables |
| 124 | + |
| 125 | +```bash |
| 126 | +# Backend selection |
| 127 | +TACO_QUERY_BACKEND=mysql |
| 128 | + |
| 129 | +# MySQL-specific configuration |
| 130 | +TACO_MYSQL_HOST=localhost |
| 131 | +TACO_MYSQL_PORT=3306 |
| 132 | +TACO_MYSQL_USER=root |
| 133 | +TACO_MYSQL_PASSWORD=your_password |
| 134 | +TACO_MYSQL_DBNAME=taco |
| 135 | +TACO_MYSQL_CHARSET=utf8mb4 |
| 136 | +``` |
| 137 | + |
| 138 | +### Defaults |
| 139 | +- **Host**: `localhost` |
| 140 | +- **Port**: `3306` |
| 141 | +- **User**: `root` |
| 142 | +- **Database Name**: `taco` |
| 143 | +- **Charset**: `utf8mb4` |
| 144 | + |
| 145 | +### Example Connection |
| 146 | + |
| 147 | +```bash |
| 148 | +export TACO_QUERY_BACKEND=mysql |
| 149 | +export TACO_MYSQL_HOST=mysql.example.com |
| 150 | +export TACO_MYSQL_PORT=3306 |
| 151 | +export TACO_MYSQL_USER=taco_user |
| 152 | +export TACO_MYSQL_PASSWORD=secure_password |
| 153 | +export TACO_MYSQL_DBNAME=taco_production |
| 154 | +export TACO_MYSQL_CHARSET=utf8mb4 |
| 155 | +``` |
| 156 | + |
| 157 | +## Quick Start Examples |
| 158 | + |
| 159 | +### Development (SQLite) |
| 160 | + |
| 161 | +```bash |
| 162 | +# No configuration needed - SQLite is the default |
| 163 | +./taco |
| 164 | +``` |
| 165 | + |
| 166 | +### Production (PostgreSQL) |
| 167 | + |
| 168 | +```bash |
| 169 | +export TACO_QUERY_BACKEND=postgres |
| 170 | +export TACO_POSTGRES_HOST=prod-db.example.com |
| 171 | +export TACO_POSTGRES_USER=taco_prod |
| 172 | +export TACO_POSTGRES_PASSWORD=$PROD_DB_PASSWORD |
| 173 | +export TACO_POSTGRES_DBNAME=taco |
| 174 | +export TACO_POSTGRES_SSLMODE=require |
| 175 | + |
| 176 | +./taco |
| 177 | +``` |
| 178 | + |
| 179 | +## Notes |
| 180 | + |
| 181 | +- **SQLite** is best for local development and testing |
| 182 | +- **PostgreSQL** is recommended for production deployments |
| 183 | +- **MSSQL** and **MySQL** are available for enterprise compatibility |
| 184 | +- Database schemas are automatically initialized on first run |
0 commit comments