Tutorial
Managing Databases from Your Phone
Complete guide to connecting, querying, and managing PostgreSQL, MySQL, MongoDB and more databases directly from Pocket Code.
3 min
By Pocket Code TeamDatabases from Your Android
Pocket Code's database module supports 8 different engines and lets you manage your data without needing a computer.
Supported engines
- PostgreSQL β Advanced relational databases
- MySQL / MariaDB β The world's most popular RDBMS
- SQLite β Local serverless databases
- MongoDB β Flexible NoSQL documents
- Redis β Cache and key-value storage
- Firestore β Firebase real-time database
- Supabase β Managed PostgreSQL with REST API
- PlanetScale β Serverless scalable MySQL
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:pass@cluster.mongodb.net/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 Pocket Code');
-- 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 Pocket Code you get a full client for 8 different engines, right in your pocket.