Skip to content

Getting started

We will connect the sample legislators database and ask how many vice presidents became president by election in the 20th century.

You need an API key from Anthropic, OpenAI, Google, Groq, xAI, Mistral, Cohere, or Hugging Face. You can instead use a ChatGPT subscription through OpenAI Codex.

If SQLsaber is not installed, follow Installation first.

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

You should now have legislators.db in the current directory.

To use your own database instead, see Database setup.

Terminal window
saber -d ./legislators.db

On first launch, SQLsaber asks you to choose an AI provider. API-key providers use an environment variable or your operating system credentials store. OpenAI Codex uses browser authentication with a ChatGPT subscription.

After setup you should see the interactive prompt.

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

SQLsaber lists relevant tables, reads their schema, writes SQL, runs the query, and explains the result. You should see the generated SQL and a short answer.

To leave interactive mode, type /exit or press Ctrl+D.

Type /help for slash commands. Type @ and press Tab to complete a table name. The full list is in Commands.

Terminal window
saber -d ./legislators.db "How many VPs became president by election in the 20th century?"

Pipe a question:

Terminal window
echo "Top 10 customers by revenue" | saber

Write the answer to a file:

Terminal window
saber "Monthly active users" > report.md

If you see No database connections configured, run saber db add mydb.

If you see Authentication not configured, run saber auth setup.

If you see Database connection failed, run saber db test mydb.