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?
2 Replies
rphlmr âš¡
rphlmr ⚡•5mo 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
Haaxor1689OP•5mo ago
thanks for the quick reply, I'll wait for the proper API if it should be coming so soon 🙂
Want results from more Discord servers?
Add your server