question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get connection details for Knex.js

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AustinGilcommented, Jan 5, 2021

WHAAAT!?!? No way! That is awesome. I’m going to try it out now. Thank you

1reaction
oguimbalcommented, Jan 5, 2021

@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 !

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found