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.
Create a fresh project with bun init and install Drizzle.
terminal

Then connect to a SQLite database with 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 creates sqlite.db and executes the query.
terminal

Now give the database a schema. Create a schema.ts file and define a movies table.
schema.ts

Generate an initial SQL migration with the drizzle-kit CLI.
terminal

The command creates a drizzle directory containing a .sql migration file and a meta directory.
File Tree

Execute these migrations with a migrate.ts script. It connects to sqlite.db, then executes all unexecuted migrations in the drizzle directory.
migrate.ts

Run the script with bun to execute the migration.
terminal

Now add some data to the database. Create a seed.ts file with the following contents.
seed.ts

Then run this file.
terminal

The database now has a schema and some sample data. Query it with Drizzle by replacing the contents of index.ts with the following.
index.ts

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

See the Drizzle docs.