---
title: Getting Started
description: Install SQLsaber, connect a database, and run your first query in under 5 minutes.
---

import { Aside, Code } from "@astrojs/starlight/components";

**Goal:** Go from zero to running your first natural language database query.

**Time:** ~3 minutes

**Prerequisites:**

- A database (PostgreSQL, MySQL, SQLite, or DuckDB)
- An API key from Anthropic, OpenAI, Google, or Groq

## 1. Install

```bash
uv tool install sqlsaber
```

<Aside type="tip">
Don't have `uv`? Install it first:

```bash
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows
winget install --id=astral-sh.uv -e
```

</Aside>

## 2. Run the setup

```bash
saber
```

On first run, SQLsaber walks you through:

1. **Database connection** — Choose your database type and enter connection details
2. **Authentication** — Enter your AI provider API key; credentials are stored in your OS keychain

<Aside type="note">
**Need a test database?** Download the legislators SQLite file:

```bash
curl -L -o legislators.db https://github.com/SarthakJariwala/sqlsaber/raw/refs/heads/main/legislators.db
```

</Aside>

## 3. Ask your first question

After setup completes, you're in interactive mode. Try:

```
> How many VPs have become presidents via election in the 20th century?
```

SQLsaber will:

1. **Discover** relevant tables
2. **Analyze** their schema
3. **Generate** SQL
4. **Execute** and explain results

<script
  src="https://asciinema.org/a/39e71PIiGJetHBPy08L1TOotB.js"
  id="asciicast-39e71PIiGJetHBPy08L1TOotB"
  async="true"
></script>

## Interactive mode commands

| Command      | Action                                 |
| ------------ | -------------------------------------- |
| `/clear`     | Clear conversation history             |
| `/exit`      | Exit SQLsaber                          |
| `@tablename` | Autocomplete table names               |
| `#your note` | Add to memory (e.g., `#dates are UTC`) |

## Non-interactive mode

Run single queries without entering the REPL:

```bash
# Direct query
saber "How many users signed up this week?"

# Specific database
saber -d production "Show me failed payments"

# Pipe from stdin
echo "Top 10 customers by revenue" | saber

# Save output
saber "Monthly active users" > report.md
```

## Next steps

- **[Add memory](/guides/memory)** — Teach SQLsaber about your database conventions
- **[Resume threads](/guides/threads)** — Continue past conversations
- **[Configure models](/guides/models)** — Switch AI providers or models
- **[Database setup](/guides/database-setup)** — SSL, connection strings, multiple databases

## Troubleshooting

| Error                                | Fix                                  |
| ------------------------------------ | ------------------------------------ |
| "No database connections configured" | Run `saber db add mydb`              |
| "Authentication not configured"      | Run `saber auth setup`               |
| "Database connection failed"         | Run `saber db test mydb` to diagnose |

For command reference, see [`saber --help`](/reference/commands) or the [full documentation](/).
