Skip to content
Tutorial

Managing Databases from Your Phone

Complete guide to connecting, querying, and managing PostgreSQL, MySQL, MongoDB and more databases directly from PocketCode.

5 min
By Pelayo Naredo

Databases from Your Android

PocketCode's database module supports many different engines and lets you manage your data without needing a computer. Some engines get a full SQL console; others (MongoDB, Redis, Firestore) only get a browser, and this post says which.

Supported engines

  • PostgreSQL — embedded on your phone (64-bit ARM, no root) or your own server
  • MySQL / MariaDB — your own server (there is no local MariaDB)
  • Neon — serverless Postgres
  • Supabase — managed PostgreSQL with a REST API
  • MongoDB Atlas — managed MongoDB clusters, opened from your Atlas account
  • MongoDB — your own server, NoSQL documents
  • PlanetScale — serverless, scalable MySQL
  • Turso — libSQL/SQLite at the edge
  • Upstash — serverless Redis
  • Redis — your own server
  • Cloudflare D1 — SQLite on Cloudflare's edge
  • Cloud Firestore — Firebase's document database

Quick connect

PostgreSQL

SQL
-- Connection setup
-- Host: db.myproject.com
-- Port: 5432
-- Database: production
-- User: admin
-- SSL: Required

-- Once connected, run queries directly
SELECT
  u.name,
  COUNT(o.id) as total_orders,
  SUM(o.amount) as total_spent
FROM users u
JOIN orders o ON u.id = o.user_id
WHERE o.created_at >= '2024-01-01'
GROUP BY u.name
ORDER BY total_spent DESC
LIMIT 10;

MongoDB

Text
# Connect to your own server or to Atlas
# URI: mongodb+srv://user:[email protected]/mydb

Paste the URI and PocketCode fills in the form (a mongodb+srv:// address is resolved with DNS over HTTPS). Test Connection does a real ping, including TLS and the login. What you get after that is the list of the database's collections with a count for each. There is no MongoDB shell, no query editor and no aggregation builder in this version, so you cannot run find or aggregate from the app.

PostgreSQL (embedded, local)

Perfect when you want a real database on the device with no server to rent. It is PostgreSQL 18.2 running inside the app, so you write standard PostgreSQL SQL. It ships for 64-bit ARM phones only (not on x86_64 emulators or Chromebooks). The app needs a connection to sign in; opening it with a session already started works offline, and after that the local database runs on the device:

SQL
-- Create local table
CREATE TABLE IF NOT EXISTS notes (
  id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  title TEXT NOT NULL,
  content TEXT,
  created_at TIMESTAMPTZ DEFAULT now(),
  updated_at TIMESTAMPTZ DEFAULT now()
);

-- Insert note
INSERT INTO notes (title, content)
VALUES ('My first note', 'Created from PocketCode');

-- Search notes (case-insensitive)
SELECT * FROM notes
WHERE title ILIKE '%pocket%'
ORDER BY updated_at DESC;

Manager features

Visual explorer

The side panel lists your connections and their tables. A table's detail screen opens its Columns, Indexes, Keys, Triggers and DDL tabs, and there are also ER diagrams, a schema designer, execution plans and backups. Remote MySQL does not list indexes, foreign keys or triggers.

Query editor

  • SQL syntax highlighting per dialect (PostgreSQL, MySQL, SQLite)
  • A row of completion suggestions for keywords, tables, views, columns and functions
  • Query history (500 entries), saved queries and several tabs
  • Export results (CSV, JSON and other formats); the console keeps at most 500 rows per query
  • MongoDB, Redis, Upstash and Firestore have no SQL console

Data viewer

  • Pages of 100 rows, ordered by primary key
  • Tap a column header to sort, and use the filter sheet (12 operators; BETWEEN does not work yet)
  • Long-press a cell to edit it, or select rows to copy or export them; editing and deleting need a usable primary key
  • Insert Row does not open a form in this version

Use cases

Production debugging

SQL
-- Find recent errors
SELECT error_message, COUNT(*) as count, MAX(created_at) as last_seen
FROM error_logs
WHERE created_at >= NOW() - INTERVAL '1 hour'
GROUP BY error_message
ORDER BY count DESC;

Quick monitoring

SQL
-- Database status
SELECT
  schemaname,
  relname as table_name,
  n_live_tup as row_count,
  pg_size_pretty(pg_total_relation_size(relid)) as total_size
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;

Emergency migrations

On Neon, Supabase, Turso and Cloudflare D1 the console starts in Read-only mode; switch it off and every write shows what it will do (and asks you to confirm a destructive one) before it runs. On any connection, dangerous statements go through a safe-mode check first.

SQL
-- Add urgent column
ALTER TABLE users ADD COLUMN phone VARCHAR(20);

-- Backfill data
UPDATE users SET phone = profiles.phone
FROM profiles WHERE users.id = profiles.user_id;

-- Verify
SELECT COUNT(*) FROM users WHERE phone IS NOT NULL;

Security

  • Credentials are stored encrypted on device
  • SSL/TLS connection support
  • SSH tunnel option for PostgreSQL and MySQL / MariaDB connections (it has no effect on the other engines)
  • PocketCode has no server of its own in between: the app talks to the local engine, to your host or to the provider's API, and connections are not synced to the cloud

Free plan limits

On the Free plan you can save one connection of your own and one local database, create up to 4 tables per connection, keep 5 saved queries and use 2 console tabs. Pro removes those caps.


Managing databases from your phone is no longer a compromise. With PocketCode you get a full client for many different engines, right in your pocket.