From 03f466b82300fedbafd011369b4a667b5113c0fd Mon Sep 17 00:00:00 2001 From: haoxin Date: Mon, 24 Feb 2014 08:58:54 +0800 Subject: [PATCH] add example of using pool directly --- Readme.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Readme.md b/Readme.md index ac99ca220..4bf6dae99 100644 --- a/Readme.md +++ b/Readme.md @@ -210,6 +210,22 @@ Unlike `end()` the `destroy()` method does not take a callback argument. ## Pooling connections +Use pool directly. +```js +var mysql = require('mysql'); +var pool = mysql.createPool({ + host : 'example.org', + user : 'bob', + password : 'secret' +}); + +pool.query('SELECT 1 + 1 AS solution', function(err, rows, fields) { + if (err) throw err; + + console.log('The solution is: ', rows[0].solution); +}); +``` + Connections can be pooled to ease sharing a single connection, or managing multiple connections.