How to get connection details for Knex.js
See original GitHub issueI’m using knex.js to connect to my Postgres DB, but in testing, I would like to connect to the pg-mem DB. For that, I think I need to know the connection details or connection string. This is what knex.js uses
connection: {
user: DB_USER,
password: DB_PASS,
database: DB_NAME,
host: DB_HOST,
port: DB_PORT,
},
Is there a way to get these details from a pg-mem instance so knex will use that instead?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
API for retrieving knex config from a connection? #1684 - GitHub
I'm passing the connection handle around and under certain circumstances want to log the name of the database being accessed. I'd rather not ......
Read more >Installation | Knex.js
The primary target environment for Knex is Node.js, you will need to install the knex library, and then install the appropriate database library:...
Read more >How to ensure the Knex connection in nodejs - Stack Overflow
The only solution I can think of is to perform a raw query like USE {DB_NAME} and use its output to decide whether...
Read more >Querying databases with Knex.js - LogRocket Blog
To use Knex and Postgres, we will have to get Knex and the pg driver installed in the app first. ... After the...
Read more >Knex.js Tutorial For Beginners - Shahed Nasser
In this section, you'll create a GET endpoint to retrieve users. You'll use Knex.js to retrieve the users. ... To retrieve data from...
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 Free
Top 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

WHAAAT!?!? No way! That is awesome. I’m going to try it out now. Thank you
@AustinGil Support for Knex.js should be ok with
pg-mem@1.5.2@obernardovieira I’m facing a problem for Sequelize, which is not that easy to solve. I’ve created a separate issue to track it. Feel free to subscribe to it !