Skip to content
Back to home
Back to blog
Tutorial

Managing Databases from Your Phone

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

3 min
By Pelayo Naredo
Managing Databases from Your Phone

Databases from Your Android

PocketCode's database module supports 9 different engines and lets you manage your data without needing a computer.

Supported engines

  • PostgreSQL — a full server embedded in the app (no root, works offline)
  • Neon — serverless Postgres
  • Supabase — managed PostgreSQL with a REST API
  • SQLite — local, serverless databases
  • MongoDB — flexible NoSQL documents
  • PlanetScale — serverless, scalable MySQL
  • Turso — libSQL/SQLite at the edge
  • Upstash — serverless Redis
  • Firestore — Firebase's real-time database

Quick connect

PostgreSQL

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

// Connect to MongoDB Atlas
// URI: mongodb+srv://user:[email protected]/mydb

// Find documents
db.products
	.find({
		category: "electronics",
		price: { $lt: 500 },
		stock: { $gt: 0 },
	})
	.sort({ rating: -1 })
	.limit(20);

// Aggregate data
db.orders.aggregate([
	{ $match: { status: "completed" } },
	{
		$group: {
			_id: "$product_id",
			total: { $sum: "$amount" },
			count: { $sum: 1 },
		},
	},
	{ $sort: { total: -1 } },
]);

SQLite (Local)

Perfect for apps that work offline:

-- Create local table
CREATE TABLE IF NOT EXISTS notes (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  title TEXT NOT NULL,
  content TEXT,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

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

-- Search notes
SELECT * FROM notes
WHERE title LIKE '%pocket%'
ORDER BY updated_at DESC;

Manager features

Visual explorer

The side panel shows all your connections organized:

  • Connections saved with color-coded types
  • Tables/Collections with folder icons
  • Columns with visible data types
  • Indexes and relationships

Query editor

  • Syntax highlighting for SQL, MongoDB queries and more
  • Autocomplete for tables, columns and functions
  • Query execution history
  • Export results to CSV or JSON

Results visualization

  • Table view with horizontal scrolling
  • Sort by any column
  • Filter results in real time
  • Copy individual cells or full rows

Use cases

Production debugging

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

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

-- 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 secure connections
  • We never store connection data on our servers

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

The tool behind this article

DB Manager

Ready to try PocketCode?

Download the app and start coding from your mobile.