Skip to main content
doc0blade47/drizzle-ormdocumentation home
Sign in

Quickstart Guide

Last updated Oct 12, 2026

Overview

Introduction

The Quickstart Guide helps you get up and running with Drizzle ORM by setting up your project, installing the necessary packages, and establishing your first database connection. Drizzle ORM connects to your database using specific database drivers, allowing you to run queries safely and efficiently in TypeScript or JavaScript.

Note

Before you begin, make sure you have Node.js installed on your computer and a running database instance ready to connect to.


Step-by-Step Installation and Configuration

Introduction

Follow these steps to install Drizzle ORM and configure your database connection.

1. Install Drizzle ORM and Your Database Driver

Install the core Drizzle ORM package along with the appropriate driver for your database. Drizzle supports many different database engines and client libraries.

Supported database drivers and packages:

  • PostgreSQL: node-postgres, postgres, neon-serverless, neon-http, vercel-postgres, bun-sql, pqlite, xata-http
  • MySQL: mysql2, @planetscale/database, @tidbcloud/serverless
  • SQLite: @libsql/client/http, @libsql/client/ws, @op-engineering/op-sqlite, sql.js
  • Other: gel

Run the installation command for your chosen setup using your preferred package manager (for example, npm):

npm install drizzle-orm mysql2

2. Configure Your Database Connection

Import the drizzle function from the module matching your driver and pass in either your database connection string, an existing connection client, or a configuration object.

Here is an example using PostgreSQL with node-postgres:

import pg from 'pg';
import { drizzle } from 'drizzle-orm/node-postgres';
 
// Option A: Pass a connection string directly
const db = drizzle('postgres://user:password@localhost:5432/dbname');
 
// Option B: Pass a pre-configured client pool
const pool = new pg.Pool({
  connectionString: 'postgres://user:password@localhost:5432/dbname',
});
const db = drizzle({ client: pool });

3. Verify the Connection

You can now use your db instance to perform queries and interact with your database tables.


Key Concepts

Introduction

Review these essential concepts to better understand how Drizzle connects to your data.

  • Database Driver: A library that enables Node.js to communicate with a specific database server (such as PostgreSQL, MySQL, or SQLite). Drizzle sits on top of these drivers to provide type safety and query building.
  • Connection String: A standard URL containing your database credentials, host, port, and database name (for example, mysql://user:password@localhost:3306/database).
  • Client / Pool: An active session manager or connection pool provided by your database driver that handles network communication with your database server.

Configuration Options

Introduction

When initializing Drizzle with the drizzle() function, you can pass an optional configuration object alongside your connection.

OptionTypeDescription
schemaRecord<string, unknown>An object containing your database tables and relations for relational queries.
loggerboolean | LoggerEnables default query logging or accepts a custom logger implementation.
casingstringDefines automatic casing transformation for column and table names.
cacheCacheOptional caching configuration for query results.

Tip

When providing a schema for MySQL databases using the mysql2 driver, you must also specify the mode property in your configuration (either mode: 'default' or mode: 'planetscale').

Warning

Always verify that your database name is explicitly included in your connection string or configuration object. Omitting the database name will cause connection initialization to fail.

Was this page helpful?