TypeError: connection.end is not a function
See original GitHub issueHi! When I use this code:
var config = {
host : 'localhost',
user : 'root',
password : 'root',
database : 'mydb',
timezone: 'utc',
multipleStatements: true
};
var connection;
var mysql = require('promise-mysql');
mysql.createConnection(config
).then(function(conn){
connection = conn;
var sql = "Select COUNT(*) From mydb";
var result = connection.query(sql);
return result;
}).then(function(result){
connection.end();
connection = {};
}).catch(function(error){
if (connection && connection.end) connection.end();
});
I’ve got error - TypeError: connection.end is not a function Why end is not a function? My nodejs version 8.10.0 Can anybody help me? Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
nodejs- TypeError: connection.connect is not a function
I am planning to use connection pooling instead of single connection, heard it allows us to reuse existing database connections instead of ...
Read more >TypeError: connection.end is not a function · Issue #102 - GitHub
Hi! When I use this code: var config = { host : 'localhost', user : 'root', password : 'root', database : 'mydb', timezone:...
Read more >Node.js with MySQL - w3resource
You can terminate a connection by calling the end() method : connection.end(function(err) { // The connection is terminated now });. This will ...
Read more >Connecting to the MySQL Database Server from Node.js
This tutorial shows you how to connect to the MySQL database server from a node.js application using the mysql module API.
Read more >Connection Pools with MariaDB Connector/Node.js (Promise ...
The createPool(options) function does not return a Promise , and therefore must be wrapped in a new Promise object if returned directly 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 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
Hi! Thank you guys! I had decided this problem!!!
Hello,
I don’t know if you resolve your problem but i have the same error using
sequelize-pool
. If you do a console.log forconnection
variable you can view that end method isn’t defined now. Instead of this method you can useconnection.close()
.