Node MySQL escape LIKE statement

Not sure why it’s escaping the % in your last example, because that works fine for me: // lifted from my code: var value=”ee20e966289cd7″; connection.query(‘SELECT * from django_session where session_key like ?’, ‘%’ + value + ‘%’, …) // Result: [ { session_key: ‘713ee20e966289cd71b936084a1e613e’, … } ] When I turn on debugging in the driver … Read more

Error: Handshake inactivity timeout in Node.js MYSQL module

Ok, the timeout comes from the Protocol.js file line:162. If you checkout node-mysql you’ll see that it is a variable “timeout” for queries. If you set the timeout to something a lot higher than 10000, the default, then the error should go away. An example is pool = require(‘mysql’).createPool({ connectionLimit : 1000, connectTimeout : 60 … Read more

Use promise to process MySQL return value in node.js

This is gonna be a little scattered, forgive me. First, assuming this code uses the mysql driver API correctly, here’s one way you could wrap it to work with a native promise: function getLastRecord(name) { return new Promise(function(resolve, reject) { // The Promise constructor should catch any errors thrown on // this tick. Alternately, try/catch … Read more

How can I respond in XML using ExpressJS?

You can use any number of the XML libraries available on npm. Here’s an example using the simply-named “xml” library: var xml = require(‘xml’); response.set(‘Content-Type’, ‘text/xml’); response.send(xml(name_of_restaurants)); See the module’s documentation for a description of how it converts JavaScript objects to XML. If you need things returned in a specific XML format, you’ll have more … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)