npm package: @huangzhuxing/dbc
Description: [![DBC CI](https://github.com/huangzhuxing/dbc/actions/workflows/ci.yml/badge.svg)](https://github.com/huangzhuxing/dbc/actions/workflows/ci.yml)
Latest version: 0.0.1

# DBC (Database Copilot)

[![DBC CI](https://github.com/huangzhuxing/dbc/actions/workflows/ci.yml/badge.svg)](https://github.com/huangzhuxing/dbc/actions/workflows/ci.yml)

![DBC Screenshot](./docs/assets/dbc-screenshot.png)

This repository contains DBC (Database Copilot), an intelligent database management CLI tool that simplifies database operations for DBAs and developers. Built on the foundation of Gemini CLI, DBC brings AI-powered database management to your terminal.

With DBC (Database Copilot) you can:

- Connect to multiple database types (MySQL, PostgreSQL, MongoDB, Redis, etc.) with natural language commands
- Execute SQL queries using plain English - no need to remember complex syntax
- Manage database drivers intelligently with automatic installation and version management
- Perform database health checks and monitoring with AI-powered insights
- Handle database migrations, backups, and recovery operations safely
- Switch between different database connections seamlessly
- Get intelligent suggestions for query optimization and performance tuning

## Quickstart

1. **Prerequisites:** Ensure you have [Node.js version 18](https://nodejs.org/en/download) or higher installed.
2. **Run the CLI:** Execute the following command in your terminal:

   ```bash
   npx @huangzhuxing/dbc
   ```

   Or install it with:

   ```bash
   npm install -g @huangzhuxing/dbc
   dbc
   ```

3. **Pick a color theme**
4. **Configure your first database connection:** DBC will guide you through setting up your database connections with natural language prompts.

You are now ready to use DBC (Database Copilot)!

### For advanced use or increased limits:

If you need to use a specific model or require a higher request capacity, you can use an API key:

1. Generate a key from [Google AI Studio](https://aistudio.google.com/apikey).
2. Set it as an environment variable in your terminal. Replace `YOUR_API_KEY` with your generated key.

   ```bash
   export GEMINI_API_KEY="YOUR_API_KEY"
   ```

For other authentication methods, including Google Workspace accounts, see the [authentication](./docs/cli/authentication.md) guide.

## Examples

Once DBC is running, you can start managing your databases with natural language.

Connect to a MySQL database:

```sh
dbc
> Connect to MySQL database at localhost:3306 with username admin
```

Query your database with natural language:

```sh
dbc
> Show me all users who registered in the last 7 days
> Find the top 10 products by sales volume this month
> Check the health of my database connections
```

### Next steps

- Learn how to [contribute to or build from the source](./CONTRIBUTING.md).
- Explore the available **[CLI Commands](./docs/cli/commands.md)**.
- If you encounter any issues, review the **[Troubleshooting guide](./docs/troubleshooting.md)**.
- For more comprehensive documentation, see the [full documentation](./docs/index.md).
- Take a look at some [popular tasks](#popular-tasks) for more inspiration.

### Troubleshooting

Head over to the [troubleshooting](docs/troubleshooting.md) guide if you're
having issues.

## Popular tasks

### Database Connection Management

Start by running `dbc` and set up your database connections.

```text
> Connect to my production MySQL database
```

```text
> Switch to my development PostgreSQL instance
```

### Query and Analysis

```text
> Show me all tables in this database
```

```text
> Find slow running queries from the last hour
```

### Database Operations

```text
> Create a backup of the users table
```

```text
> Check database performance metrics
```

### Schema Management

```text
> Show me the schema for the orders table
```

```text
> Find all foreign key relationships in this database
```

### Monitoring and Health Checks

```text
> Check the health of all my database connections
```

```text
> Show me database size and storage usage
```

## Terms of Service and Privacy Notice

For details on the terms of service and privacy notice applicable to your use of Gemini CLI, see the [Terms of Service and Privacy Notice](./docs/tos-privacy.md).