sqlite create new db file push programatically

Hi, I'm using better-sqlite3 with drizzle in my electron project and for my use case, I have some binary format data that my app can read, and I'd like to make an export to a new sqlite .db file. I have the schemas and everything set up but I want to take the db file path from user input and just create new one on the spot and fill it with data. Is there a way to push my schema to this db file programatically just like drizzle-kit push does normally?
5 Replies
rphlmr ⚡
rphlmr ⚡6mo ago
👋 drizzle kit will soon have a programmatic API (next week I guess, july 30th). For now you can pass args to drizzle-kit (https://orm.drizzle.team/kit-docs/commands#prototype--push) ex:
$ drizzle-kit push --schema=src/schema.ts --url=postgresql://user:pass@host:port/db_name
$ drizzle-kit push --schema=src/schema.ts --url=postgresql://user:pass@host:port/db_name
I use drizzle kit programmatically like this for now
import { execSync } from "node:child_process";

execSync("drizzle-kit xxx");
import { execSync } from "node:child_process";

execSync("drizzle-kit xxx");
Maybe it can help?
Drizzle ORM - List of commands
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Haaxor1689
Haaxor1689OP6mo ago
thanks for the quick reply, I'll wait for the proper API if it should be coming so soon 🙂
navanshu
navanshu6d ago
Any update on the api, it would be great if we could just build a single file and send it the app/docker image to prod and update the database using it
rphlmr ⚡
rphlmr ⚡6d ago
GitHub
drizzle-orm/drizzle-kit/src/api.ts at main · drizzle-team/drizzle-orm
Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅 - drizzle-team/drizzle-orm
rphlmr ⚡
rphlmr ⚡6d ago
Import from “drizzle-kit/api” 🚀

Did you find this page helpful?