---
title: "Connecting Databases"
description: "To start querying and managing your database with Drizzle ORM, you need to connect it using a driver. Drizzle supports a wide variety of relational databases — including PostgreSQL, MySQL, SQLite, ..."
last_updated: "2026-10-12T08:15:21.949612+00:00"
canonical_url: "https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/guide/getting-started/connecting-databases"
---

## Overview

To start querying and managing your database with Drizzle ORM, you need to connect it using a driver. Drizzle supports a wide variety of relational databases — including PostgreSQL, MySQL, SQLite, SingleStore, and Gel — alongside numerous serverless drivers, cloud data APIs, and object-relational mapping extensions. 

Connecting your database typically involves passing a connection string, a configuration object, or an existing database client instance into Drizzle's initialization function.

---

## Supported Drivers and Providers

Drizzle provides specialized integration packages for different database engines and execution environments. 

Supported database dialects: `postgresql`, `mysql`, `sqlite`, `singlestore`, `gel`.

Supported driver and provider package names:
- **PostgreSQL / Serverless Postgres:** `@aws-sdk/client-rds-data`, `@electric-sql/pglite`, `pg`, `postgres`, `@vercel/postgres`, `@neondatabase/serverless`
- **MySQL / Serverless MySQL:** `mysql2`, `@planetscale/database`, `@tidbcloud/serverless`
- **SQLite / LibSQL:** `@libsql/client`, `@libsql/client/sqlite3`, `@libsql/client/node`, `@libsql/client/ws`, `@libsql/client/http`, `@libsql/client-wasm`, `better-sqlite3`
- **Other Environments:** `gel`, `netlify-db`, `cloudflare/workers-types` (Durable Objects SQLite), `@prisma/client` (via Prisma extensions)

---

## How to Connect Your Database

### Connecting via Connection String

The simplest way to connect to most databases is by passing the connection string directly as a string parameter.

```typescript
import { drizzle } from 'drizzle-orm/node-postgres';

const db = drizzle('postgres://user:password@host:port/database_name');
```

### Connecting via Configuration Object

You can pass a configuration object containing connection details (such as a URL, host, user, password, or driver-specific options) along with optional schema definitions or loggers.

```typescript
import { drizzle } from 'drizzle-orm/node-postgres';

const db = drizzle({
  connection: {
    connectionString: process.env.DATABASE_URL,
    ssl: true,
  },
});
```

### Connecting via an Existing Client Instance

If your application already manages a database connection pool or client, you can pass that pre-configured client directly into Drizzle.

```typescript
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';

const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const db = drizzle({ client: pool });
```

---

## Key Concepts

* **Driver:** A software package or layer that allows Drizzle to communicate with your specific database engine or serverless environment.
* **Dialect:** The specific flavor of SQL spoken by your database system (e.g., PostgreSQL, MySQL, SQLite).
* **Connection String:** A URI containing your database credentials, host, port, and database name.
* **Mock Database:** A simulated database instance generated via `drizzle.mock()` that lets you build queries or initialize schemas without an active network connection to a live database.

---

## Tips and Warnings

> [!TIP]
> When working with serverless environments or edge functions (such as Neon, Vercel Postgres, or LibSQL), prefer HTTP-based or serverless drivers to handle fast connection cold starts and stateless requests efficiently.

> [!NOTE]
> If you are using MySQL or SQLite with database migrations, Drizzle automatically manages SQL statement breakpoints to ensure that statements which cannot run together in a single transaction execute safely one-by-one.

> [!WARNING]
> When supplying a schema object alongside `mysql2` or `singlestore` drivers, you must explicitly specify the `mode` parameter (e.g., `mode: 'default'` or `mode: 'planetscale'`) in your configuration to avoid runtime errors.

## Related

- [Quickstart Guide](https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/guide/getting-started/quickstart-guide)
- [Configuring Drizzle Kit](https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/guide/configuration/configuring-drizzle-kit)


## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/llms.txt) for all pages in this wiki.
