Skip to main content
Drizzle is an ORM that supports both a SQL-like “query builder” API and an ORM-like Queries API. It supports the bun:sqlite built-in module.
Let’s get started by creating a fresh project with bun init and installing Drizzle.
terminal

Then we’ll connect to a SQLite database using the bun:sqlite module and create the Drizzle database instance.
db.ts

To see the database in action, add these lines to index.ts.
index.ts

Then run index.ts with Bun. Bun will automatically create sqlite.db and execute the query.
terminal

Lets give our database a proper schema. Create a schema.ts file and define a movies table.
schema.ts

We can use the drizzle-kit CLI to generate an initial SQL migration.
terminal

This creates a new drizzle directory containing a .sql migration file and meta directory.
File Tree

We can execute these migrations with a migrate.ts script. This script creates a new connection to a SQLite database that writes to sqlite.db, then executes all unexecuted migrations in the drizzle directory.
migrate.ts

We can run this script with bun to execute the migration.
terminal

Now that we have a database, let’s add some data to it. Create a seed.ts file with the following contents.
seed.ts

Then run this file.
terminal

We finally have a database with a schema and some sample data. Let’s use Drizzle to query it. Replace the contents of index.ts with the following.
index.ts

Then run the file. You should see the three movies we inserted.
terminal

Refer to the Drizzle website for complete documentation.