Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection does not seem to be terminated #67

Closed
obourne opened this issue Apr 21, 2020 · 3 comments
Closed

Connection does not seem to be terminated #67

obourne opened this issue Apr 21, 2020 · 3 comments

Comments

@obourne
Copy link

obourne commented Apr 21, 2020

When running the example code connecting to local mysql database https://www.atdatabases.org/docs/mysql it connects and queries fine but the node process doesn't automatically terminate so I have to use ctrl-c to do it. In other libraries like mysql you need to call connection.end(), I can't see that in this library but I tried db.dispose() and that failed saying there were no connections.

There may be doing something I'm doing wrong here but I compared the behaviour against the mysql module and that terminates fine. I prefer the interface to this library so would be interested in using it but at the moment don't have the confidence to do so.

@cdock1029
Copy link

wondering about this as well, if the connection should be closed

@ForbesLindesay
Copy link
Owner

db.dispose() should work fine. Can you try:

const connect = require('@databases/mysql');
const {sql} = require('@databases/mysql');

const db = connect();

db.query(sql`SELECT 1 + 41;`).then(
  results => console.log(results),
).then(() => db.dispose()).catch(err => {
  console.error(err);
  process.exit(1);
});

That's working for me, and exiting cleanly.

If that works for you, could you submit a pull request to update the examples for pg and mysql:

@obourne
Copy link
Author

obourne commented May 7, 2020

Thanks for you response and sorry for the delay in mine, I will look into this next week and get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants