https://www.npmjs.com/package/mysql#multiple-statement-queries
How do I allow multiple statements when pooling? I don't see a way to set options via getConnection nor docs about except on createConnection.
module.exports = {
connect: (config) => {
return bluebird.try(() => {
pool = bluebird.promisifyAll(mysql.createPool(config));
return pool;
});
},
query: (sql, placeholders) => {
return bluebird.using(pool.getConnectionAsync(), (conn) => {
return bluebird.promisify(conn.query, {context: conn})(sql, placeholders);
});
}
};
The multipleStatements:true option (and all other options, as far as I can tell) works with createPool, the same as with createConnection.
Be aware that when you sent multiple statements:
select 0; select1;
you will get back an array of result arrays:
[
[
{"0": 0}
],
[
{"1": 1}
]
]
Hi @fourq, I hope @dkloke answered your question :)
You can find as the first sentence of the pool options documentation (https://www.npmjs.com/package/mysql#connection-options):
Pools accept all the same options as a connection.
Always feel free to let us know if there is a way to help improve the documentation!
Most helpful comment
The
multipleStatements:trueoption (and all other options, as far as I can tell) works withcreatePool, the same as withcreateConnection.Be aware that when you sent multiple statements:
you will get back an array of result arrays: