afterCreate in Pool with better-sqlite3
See original GitHub issueEnvironment
Knex version: 1.0.1
Bug
- After switching from sqlite3 to better-sqlite3 we are having issues with the following line of code:
knexConfig.pool = { afterCreate: (conn, cb) => conn.run("PRAGMA foreign_keys = ON", cb), };
- Error:
TypeError: conn.run is not a function at afterCreate (src/shared/database/configurations/KnexConfigFactory.ts:9:128) at node:internal/util:360:7 at new Promise (<anonymous>) at afterCreate (node:internal/util:346:12) at create (node_modules/knex/lib/client.js:252:50)
Question
Is this a known bug or is there another way to use foreign keys with better-sqlite3?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Installation | Knex.js
afterCreate callback (rawDriverConnection, done) is called when the pool aquires a new connection from the database server. done(err, connection) callback ...
Read more >better-sqlite-pool - npm
A connection pool for the module better-sqlite3. Using this module to open pools and acquire connections, and release the connection once it has ......
Read more >Database configuration - Strapi Developer Docs
pool. Optional, Database pooling options, Object, - ... afterCreate, Callback function to execute custom logic when the pool acquires a new connection.
Read more >knex | Yarn - Package Manager
PostgreSQL: Explicit jsonb support for custom pg clients #5201; SQLite: Support returning with sqlite3 and better-sqlite3 #5285; MSSQL: Implement mapBinding ...
Read more >Browse SQL Technical Problem Clusters - Code Grepper
... show query code after create table in sql · access mysql without sudo ... mysql disable root login · const pool =...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep - will try and take a look before the weekend!
better-sqlite3
’sDatabase
class doesn’t have arun()
method, but it does have anexec()
method. There’s also apragma()
method specifically for executing PRAGMA statements. From the docs:You can probably do something like (not tested):