Deploy a database sandbox
Deploy a database sandbox
Set up a database on a Quake AI VM for prototyping and local development. Choose between SQLite (zero overhead, file-based) and PostgreSQL (tuned for low-RAM tiers).
What you will learn:
- When SQLite vs PostgreSQL is the right fit for a sandbox
- How to install and seed a SQLite database
- How to install PostgreSQL and tune it for a 1 GiB RAM tier
- How to create a database, role, and remote-connection rules
- How to connect from your local machine over the public network
Prerequisites#
- A Quake AI account with an active project, see the Quickstart if you have not signed up
- An SSH key pair uploaded to your account
- A running VM you can SSH into, or follow Launch your first server to launch one
Option A: SQLite#
SQLite is a file-based database that runs inside your application process. No separate server, no extra RAM usage. Ideal for prototyping, personal projects, and applications with moderate write throughput.
Install and create a database#
SSH into your VM and install SQLite:
sudo apt update && sudo apt install -y sqlite3Create a test database:
sqlite3 ~/myapp.db << 'EOF'
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO users (name, email) VALUES ('Alice', '[email protected]');
INSERT INTO users (name, email) VALUES ('Bob', '[email protected]');
SELECT * FROM users;
EOFConnect from your application#
SQLite databases are regular files. Any application on the same VM can connect by path:
- Node.js:
npm install better-sqlite3;new Database('/home/ubuntu/myapp.db') - Python:
import sqlite3;sqlite3.connect('/home/ubuntu/myapp.db')
When to use SQLite#
- Single-application prototypes
- Read-heavy workloads with moderate writes
- When you want zero database administration
Option B: PostgreSQL#
PostgreSQL requires more RAM but gives you a production-grade SQL database for prototyping schemas, testing queries, and developing against a real database engine.
Install and tune for 1 GB RAM#
SSH into your VM and install PostgreSQL:
sudo apt update && sudo apt install -y postgresql postgresql-clientTune the configuration for the Developer Plan's memory constraints:
sudo tee /etc/postgresql/16/main/conf.d/dev-plan.conf > /dev/null << 'EOF'
shared_buffers = 128MB
effective_cache_size = 256MB
work_mem = 4MB
maintenance_work_mem = 32MB
max_connections = 20
wal_buffers = 4MB
checkpoint_completion_target = 0.9
EOF
sudo systemctl restart postgresqlCreate a database and user#
sudo -u postgres psql << 'EOF'
CREATE USER devuser WITH PASSWORD 'devpass';
CREATE DATABASE devdb OWNER devuser;
GRANT ALL PRIVILEGES ON DATABASE devdb TO devuser;
EOFTest the connection:
psql -U devuser -d devdb -h localhost -c "SELECT version();"Allow remote connections (optional)#
To connect to PostgreSQL from your local machine, update the security group and PostgreSQL configuration:
-
Add a security group rule for TCP port 5432 (see the security group pattern from Deploy an API service).
-
Configure PostgreSQL to listen on all interfaces:
sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" \
/etc/postgresql/16/main/postgresql.conf
echo "host devdb devuser 0.0.0.0/0 scram-sha-256" | \
sudo tee -a /etc/postgresql/16/main/pg_hba.conf
sudo systemctl restart postgresql- Connect from your local machine:
psql -U devuser -d devdb -h YOUR_INSTANCE_IPNext steps#
- Deploy an API service: combine a database with an API server
- Self-Managed PostgreSQL template: automate this setup with OpenTofu
- Block storage concepts: add a dedicated volume for database files
See also#
Usage Guidelines
The sample code, software libraries, command line tools, proofs of concept, templates, and other related technology on this page (including any of the foregoing that is provided by Quake AI personnel) is provided to you as Quake AI Content under the Quake AI Customer Agreement, or the relevant written agreement between you and Quake AI (whichever applies). Do not use this Quake AI Content in your production accounts, or on production or other critical data. You are responsible for testing, securing, and optimizing the Quake AI Content (such as sample code) as appropriate for production grade use based on your specific quality control practices and standards. Deploying Quake AI Content may incur Quake AI charges for creating or using Quake AI chargeable resources, such as running Compute instances or storing data in Object Storage. Your use is also subject to the Acceptable Use Policy.
For the full policy, see Usage Guidelines.
Last validated: 26.05.2026
Quick answers
- Why does `openstack image save` write a 0-byte file for my boot-from-volume instance?CLI
- Why does `openstack server create` fail with "Only volume-backed servers are allowed for flavors with zero disk"?CLIAPITerraform
- Why does my project still have a 10 GiB Cinder volume after I deleted my instance?CLIAPI