Error: Cannot open database because the directory does not exist

This is my config (in root)
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
schema: './src/db/schema.ts',
driver: 'better-sqlite',
dbCredentials: {
url: 'file:/Users/meexa/Documents/personal/my-app/sqlite.db',
},
verbose: true,
strict: true,
out: 'drizzle',
});
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
schema: './src/db/schema.ts',
driver: 'better-sqlite',
dbCredentials: {
url: 'file:/Users/meexa/Documents/personal/my-app/sqlite.db',
},
verbose: true,
strict: true,
out: 'drizzle',
});
My client file (/src/db/index.ts)
import { drizzle } from 'drizzle-orm/bun-sqlite';
import Database from 'better-sqlite3';
import { migrate } from 'drizzle-orm/better-sqlite3/migrator';
import { users } from './schema';

const sqlite = new Database('file:/Users/meexa/Documents/personal/my-app/sqlite.db');
export const db = drizzle(sqlite);

migrate(db, { migrationsFolder: 'drizzle' });

const result = await db.select().from(users);
import { drizzle } from 'drizzle-orm/bun-sqlite';
import Database from 'better-sqlite3';
import { migrate } from 'drizzle-orm/better-sqlite3/migrator';
import { users } from './schema';

const sqlite = new Database('file:/Users/meexa/Documents/personal/my-app/sqlite.db');
export const db = drizzle(sqlite);

migrate(db, { migrationsFolder: 'drizzle' });

const result = await db.select().from(users);
sqlite.db is in the root of my project
Solution:
Updated my setup and now it works. ```ts import { defineConfig } from 'drizzle-kit'; ...
Jump to solution
2 Replies
Meexa
MeexaOP11mo ago
I've also tried file:./sqlite.db
Solution
Meexa
Meexa11mo ago
Updated my setup and now it works.
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
schema: './src/db/schema.ts',
driver: 'better-sqlite',
dbCredentials: {
url: './sqlite.db',
},
verbose: true,
strict: true,
out: 'drizzle',
});
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
schema: './src/db/schema.ts',
driver: 'better-sqlite',
dbCredentials: {
url: './sqlite.db',
},
verbose: true,
strict: true,
out: 'drizzle',
});
import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';
import { migrate } from 'drizzle-orm/libsql/migrator';

import * as schema from './schema';

export const db = drizzle(createClient({ url: 'file:./sqlite.db' }), { schema });

migrate(db, { migrationsFolder: 'drizzle' });
import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';
import { migrate } from 'drizzle-orm/libsql/migrator';

import * as schema from './schema';

export const db = drizzle(createClient({ url: 'file:./sqlite.db' }), { schema });

migrate(db, { migrationsFolder: 'drizzle' });
Want results from more Discord servers?
Add your server