

Any type of connection error (handshake or network) is considered a fatal. Am I misunderstanding the Node MySQL documentation? Is there a better way? let lineReader = require('readline') Every method you invoke on a connection is queued and executed in sequence. It doesn't seem right to close and reconnect each time like that. I was getting the Cannot enqueueafter invoking quit, until I removed the. So my INSERT function gets called several times. In a real web application, you have to connect to the same database many times. What to do appropriately Create a connection window where you can request access many times. Asking for help, clarification, or responding to other answers. socket.on Step 2: Create a SQL database for Node.js development Node.js MySQL - W3Schools. I put connection.end() as the last line of the code, everything works fine. I used it once, so please destroy it properly. Thanks for contributing an answer to Stack Overflow Please be sure to answer the question.Provide details and share your research But avoid. Cannot enqueue Query after invoking quit. Database connection error: Error: Cannot enqueue Query after invoking quit. You'll have to do a lot of refactoring to correct that (I wouldn't have enough time to rewrite your code), but that's the reason. Error: Cannot enqueue Handshake after invoking quit. query() method chronologically after you called the. It pings an Azure API that returns 100 records at a time, with a next URL to retrieve the next 100, until the end of the data set. Thanks So the issue is that in your code, line 139 you are calling the. If I move the MySQL connection object and the connection.end() call into the lineReader.createInterface().on() block, it works - the script correctly terminates at the end.but it's creating a new connection for every INSERT statement. Im trying to connect to the database of my nodejs dockerized project and Im getting this err that I dont understand, Ive googled but I cant find a. Cannot enqueue Handshake after invoking quit Codegrepr. Cannot enqueue Query after invoking quit.

Just create a connection on server startup and use the. 462 - GitHub Use Node.js to query a database - Azure SQL Database & SQL node js close sql cnnection. If I comment out the connection.end() line, it works, but the script hangs (doesn't close/end) when it completes, requiring me to hit ctrl-c to end it. Note: If youre serving web requests, then you shouldnt be ending connections on every request.
Cannot enqueue query after invoking quit. code#
Nevertheless, the code below doesn't work, because the connection.end() method is called before the SQL queries can run. According to the Node MySQL documentation ( ):Įvery method you invoke on a connection is queued and executed in sequence.Ĭlosing the connection is done using end() which makes sure all remaining queries are executed before sending a quit packet to the mysql server.
