Skip to content

Deploy a database sandbox

Tutorial · Updated May 2026

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#

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:

bash
sudo apt update && sudo apt install -y sqlite3

Create a test database:

bash
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;
EOF

Connect 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:

bash
sudo apt update && sudo apt install -y postgresql postgresql-client

Tune the configuration for the Developer Plan's memory constraints:

bash
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 postgresql

Create a database and user#

bash
sudo -u postgres psql << 'EOF'
CREATE USER devuser WITH PASSWORD 'devpass';
CREATE DATABASE devdb OWNER devuser;
GRANT ALL PRIVILEGES ON DATABASE devdb TO devuser;
EOF

Test the connection:

bash
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:

  1. Add a security group rule for TCP port 5432 (see the security group pattern from Deploy an API service).

  2. Configure PostgreSQL to listen on all interfaces:

bash
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
  1. Connect from your local machine:
bash
psql -U devuser -d devdb -h YOUR_INSTANCE_IP

Next steps#

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

Was this page helpful?