Configure Drizzle to work with Turso
Install Drizzle and the libSQL SDK
package.json
to include three new scripts
:Retrieve database credentials
.env
.Create a Drizzle schema
Configure Drizzle Kit
drizzle.config.ts
in the root of your project with the following:dotenv
above, but if you’re using something like Next.js, Remix, Astro, or Vite, you can use their built-in environment variables manager to source these values.Connect Drizzle with libSQL
Database migrations
drizzle-kit
.Whenever you make changes to the schema, run db:generate
:db:migrate
:Query
Connect Drizzle Studio
Define custom vector type
db/schema.ts
, add the following:Create a table with a vector column
float32Array
to create a column that stores vectors:Create a vector index
Insert vector data
Query vector data