# db shell

> db shell — Turso documentation.
> Canonical HTML: https://tursodb.cn/docs/cli/db/shell/
> Upstream Source (MIT): https://docs.turso.tech/cli/db/shell
> Language: en

---
You can connect directly to a Turso database by using the following command:

```bash
turso db shell <database-name> [sql] [flags]
```

## Flags

| Flag | Description |
| - | - |
| `--instance <instance>` | Connect to the specified database instance. |
| `--location <location-code>` | Connect to the database at the specified location. |
| `--proxy <url>` | The proxy to use when connecting to the database. |

## Examples

### Execute SQL

You can execute SQL directly against a database using the shell:

```bash
turso db shell <database-name> "SELECT * FROM users"
```

### Database dump

You can dump the contents of a Turso database using the following command:

```bash
turso db shell <database-name> .dump > dump.sql
```

<div class="doc-callout doc-callout-info"><div class="doc-callout-title">NOTE</div><div class="doc-callout-body">

The `.dump` can be used to rebuild a database and doesn't contain any libSQL or SQLite internal tables.

</div></div>


### Load from dump

You can load a dump file into a new database using the following command:

```bash
turso db shell <database-name> < dump.sql
```

### Shell with libSQL server

If you're using `turso dev` locally, you can use the shell by providing the URL to your database:

```bash
turso db shell http://127.0.0.1:8080
```
