Using drizzle with dynamic drivers

Hi! How can i use drizzle with dynamic drivers ? I am using it in my frontend, but the db is mainly handles by backend using sqlalchemy. So for frontend, i just introspect db and pull the schema and relations from it. Worked fine for introspect since it asks for stuff and i can pull in from env, but when i want to make db i am confused on how to do. Because there are different packages and different formats
1 Reply
Mini
MiniOP4mo ago
drizzle.config.ts
import { defineConfig } from 'drizzle-kit';
import * as dotenv from 'dotenv';

dotenv.config();

export default defineConfig({
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
dialect: process.env.DIALECT || 'postgres',
schema: './src/lib/server/drizzle/schema.ts',
out: './src/lib/server/drizzle',
dbCredentials: {
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
url: process.env.DATABASE_URL || ''
}
});
import { defineConfig } from 'drizzle-kit';
import * as dotenv from 'dotenv';

dotenv.config();

export default defineConfig({
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
dialect: process.env.DIALECT || 'postgres',
schema: './src/lib/server/drizzle/schema.ts',
out: './src/lib/server/drizzle',
dbCredentials: {
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
url: process.env.DATABASE_URL || ''
}
});
Confused on how to make db.ts file. I can install 3 drivers for 3 db but they have different imports and structure
Want results from more Discord servers?
Add your server