Skip to main content

Quick Start Example

Get started with Queryly in under a minute:
1

Add your first connection

queryly connect add
You’ll be prompted to enter:
  • Connection name: e.g., “LocalDB”
  • Database type: SQLite, PostgreSQL, MySQL, or SQL Server
  • Connection string: e.g., Data Source=mydb.db
The connection will be tested before saving.
2

List your connections

queryly connect list
Shows all saved connections with their type and last used date.
3

Explore your database

queryly schema list LocalDB
queryly data browse LocalDB users

Working with a SQLite Database

This example demonstrates a complete workflow from creating a database to exporting data.
1

Create a test database

First, create a SQLite database with some sample data:
sqlite3 myapp.db
CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT);
INSERT INTO users VALUES (1, 'Alice', '[email protected]');
INSERT INTO users VALUES (2, 'Bob', '[email protected]');
.quit
2

Add to Queryly

Register the database with Queryly:
queryly connect add
When prompted, enter:
  • name: MyApp
  • type: SQLite
  • connection string: Data Source=myapp.db
 Connection test successful!
 Connection 'MyApp' saved
3

Explore the schema

View database structure:
queryly schema list MyApp
Tables in MyApp:
┌──────────┬──────────┬──────────┐
│ Name     │ Rows     │ Type     │
├──────────┼──────────┼──────────┤
│ users    │ 2        │ Table    │
└──────────┴──────────┴──────────┘
View table structure:
queryly schema info MyApp users
Table: users
┌──────────┬──────────┬────────────┬─────────────┐
│ Column   │ Type     │ Nullable   │ Default     │
├──────────┼──────────┼────────────┼─────────────┤
│ id       │ INTEGER  │ NO         │ PRIMARY KEY │
│ name     │ TEXT     │ YES        │             │
│ email    │ TEXT     │ YES        │             │
└──────────┴──────────┴────────────┴─────────────┘
4

Browse the data

View table contents:
queryly data browse MyApp users
┌─────┬─────────┬─────────────────────┐
│ id  │ name    │ email               │
├─────┼─────────┼─────────────────────┤
│ 1   │ Alice   │ [email protected]
│ 2   │ Bob     │ [email protected]
└─────┴─────────┴─────────────────────┘
Showing 2 of 2 row(s)
5

Query the data

Enter interactive query mode:
queryly data query MyApp
SQL> SELECT * FROM users WHERE name LIKE 'A%'
┌─────┬─────────┬─────────────────────┐
│ id  │ name    │ email               │
├─────┼─────────┼─────────────────────┤
│ 1   │ Alice   │ [email protected]
└─────┴─────────┴─────────────────────┘
Showing 1 of 1 row(s) | Query time: 1.45ms
SQL> exit
6

Export the data

Export to CSV or JSON:
queryly data export MyApp users csv
✓ Exported 2 rows to users.csv
queryly data export MyApp users json
✓ Exported 2 rows to users.json

Interactive Query Session

Demonstrates advanced querying with real terminal output:
$ queryly data query MyDB

Query Mode - MyDB
Enter SQL queries. Type 'exit' to quit.
Count all users:
SQL> SELECT COUNT(*) FROM users
┌────────────┐
│ COUNT(*)   │
├────────────┤
│ 1234       │
└────────────┘
Showing 1 of 1 row(s) | Query time: 2.34ms
Retrieve user details:
SQL> SELECT name, email FROM users LIMIT 5
┌──────────────┬──────────────────────┐
│ name         │ email                │
├──────────────┼──────────────────────┤
│ Alice Smith  │ [email protected]
│ Bob Jones    │ [email protected]
│ Carol Lee    │ [email protected]
│ David Kim    │ [email protected]
│ Emma Wilson  │ [email protected]
└──────────────┴──────────────────────┘
Showing 5 of 5 row(s) | Query time: 1.23ms
Exit query mode:
SQL> exit
Exited query mode.

Multi-Database Workflow

Managing multiple databases efficiently:
1

Add multiple connections

# Add development database
queryly connect add
# name: Dev-SQLite, type: SQLite, connection: Data Source=./dev.db

# Add staging database  
queryly connect add
# name: Staging-PostgreSQL, type: PostgreSQL
# connection: Host=localhost;Database=staging;Username=postgres;Password=pass

# Add production database (read-only)
queryly connect add
# name: Prod-MySQL, type: MySQL
# connection: Server=prod.example.com;Database=app;User=readonly;Password=secret
2

List all connections

queryly connect list
Saved Connections:
┌──────────────────────┬──────────────┬─────────────────────┐
│ Name                 │ Type         │ Last Used           │
├──────────────────────┼──────────────┼─────────────────────┤
│ Dev-SQLite           │ SQLite       │ 2026-03-12 10:30    │
│ Staging-PostgreSQL   │ PostgreSQL   │ 2026-03-11 14:22    │
│ Prod-MySQL           │ MySQL        │ 2026-03-10 09:15    │
└──────────────────────┴──────────────┴─────────────────────┘
3

Compare schemas across environments

# Check dev schema
queryly schema list Dev-SQLite

# Check staging schema
queryly schema list Staging-PostgreSQL

# Verify production schema
queryly schema list Prod-MySQL
4

Test all connections

queryly connect test Dev-SQLite
queryly connect test Staging-PostgreSQL
queryly connect test Prod-MySQL

Data Export Workflows

Export Single Table

# Export users table to CSV
queryly data export MyDB users csv
Output:
✓ Exported 1,234 rows to users.csv
Generated CSV:
id,name,email
1,Alice,[email protected]
2,Bob,[email protected]

Export to JSON

# Export orders table to JSON
queryly data export MyDB orders json
Output:
✓ Exported 5,678 rows to orders.json
Generated JSON:
[
  {
    "id": 1,
    "customer_id": 101,
    "total": 99.99,
    "created_at": "2026-03-01T10:00:00Z"
  },
  {
    "id": 2,
    "customer_id": 102,
    "total": 149.50,
    "created_at": "2026-03-02T14:30:00Z"
  }
]

Bulk Export Workflow

1

List all tables

queryly schema list MyDB
2

Export each table

queryly data export MyDB users csv
queryly data export MyDB orders csv
queryly data export MyDB products csv
3

Organize exports

mkdir -p exports/mydb-$(date +%Y%m%d)
mv *.csv exports/mydb-$(date +%Y%m%d)/

Schema Exploration

View All Tables

queryly schema list MyDB
Tables in MyDB:
┌──────────────┬──────────┬──────────┐
│ Name         │ Rows     │ Type     │
├──────────────┼──────────┼──────────┤
│ users        │ 1,234    │ Table    │
│ orders       │ 5,678    │ Table    │
│ products     │ 890      │ Table    │
│ categories   │ 45       │ Table    │
└──────────────┴──────────┴──────────┘

View Table Details

queryly schema info MyDB users
Table: users
┌──────────────┬──────────────┬────────────┬─────────────────┐
│ Column       │ Type         │ Nullable   │ Default         │
├──────────────┼──────────────┼────────────┼─────────────────┤
│ id           │ INTEGER      │ NO         │ PRIMARY KEY     │
│ name         │ VARCHAR(100) │ NO         │                 │
│ email        │ VARCHAR(255) │ NO         │                 │
│ created_at   │ TIMESTAMP    │ YES        │ CURRENT_TIME    │
│ updated_at   │ TIMESTAMP    │ YES        │ CURRENT_TIME    │
└──────────────┴──────────────┴────────────┴─────────────────┘

View Schema as Tree

queryly schema tree MyDB
MyDB
├── users
│   ├── id (INTEGER, PRIMARY KEY)
│   ├── name (VARCHAR)
│   └── email (VARCHAR)
├── orders
│   ├── id (INTEGER, PRIMARY KEY)
│   ├── user_id (INTEGER, FOREIGN KEY)
│   └── total (DECIMAL)
└── products
    ├── id (INTEGER, PRIMARY KEY)
    └── name (VARCHAR)

Connection Management

Add Connection Interactively

queryly connect add
Example session:
? Connection name: LocalDB
? Database type: SQLite
? Connection string: Data Source=./myapp.db

Testing connection...
✓ Connection test successful!
✓ Connection 'LocalDB' saved

Test Connection

queryly connect test LocalDB
Testing connection to 'LocalDB'...
✓ Connection successful
Database: SQLite
Path: ./myapp.db

Remove Connection

queryly connect remove OldDB
? Are you sure you want to remove 'OldDB'? (y/n): y
✓ Connection 'OldDB' removed

Advanced Query Examples

Aggregation Queries

SQL> SELECT department, COUNT(*) as employee_count, AVG(salary) as avg_salary 
     FROM employees 
     GROUP BY department

Join Queries

SQL> SELECT u.name, COUNT(o.id) as order_count 
     FROM users u 
     LEFT JOIN orders o ON u.id = o.user_id 
     GROUP BY u.name

Complex Filtering

SQL> SELECT * FROM products 
     WHERE price BETWEEN 10 AND 100 
     AND category IN ('Electronics', 'Books') 
     ORDER BY price DESC 
     LIMIT 20

Tips and Best Practices

Use Descriptive Names: Name connections clearly like Dev-SQLite, Staging-PostgreSQL, Prod-ReadOnly-MySQL to avoid confusion.
Test Before Querying: Always run queryly connect test <name> before working with a new connection to verify credentials.
Browse Before Exporting: Use queryly data browse to preview data before exporting large tables.
Use Query Mode for Exploration: The interactive query mode is perfect for ad-hoc analysis without switching tools.
For production databases, always use read-only credentials to prevent accidental data modifications.

Next Steps

Build docs developers (and LLMs) love