I want to run PRAGMA journal_mode = WAL
on my database connection as soon as it is connected using the Kysely library.
Here's what I've tried:
const dialect = new SqliteDialect({
database: new SQLite(":memory:"),
onCreateConnection: async connnection => {
const pragmaQuery = sql<string>`PRAGMA journal_mode = WAL`;
connection.executeQuery(pragmaQuery.compile());
},
});
However, pragmaQuery.compile()
requires a reference to the database, which I don't have in this function's scope. (I instantiate db
below, which needs dialect
as an argument.)
I'm having trouble using the DatabaseConnection interface, as it has very few callable methods.
Option A (execute raw SQL via Kysely):
Option B (execute SQL directly on SQLite instance):