title: node.js / node_mysql - stale connections get "NO database selected" error
body: <p>We have a <em>node.js</em> app that uses <a href="https://github.com/felixge/node-mysql/" rel="nofollow">node_msyql</a>, a great little library for accessing MySQL databases.</p>
  
  <p>Unfortunately, if our connection is not used for maybe 8-10 hours, the next time we try to run a query, we get a <code>"No database selected"</code> error back from the server. We need to add a <code>"USE db"</code> somewhere, but I can't figure out where.</p>
  
  <p>Now, it makes sense to me that connections would go stale, and it seems as though node_mysql is refreshing those stale connections, but there doesn't seem to be a way to make sure that the right db is connected.  I was looking for a <code>.connected()</code> callback or event or something that would let me make sure the correct DB was alway <code>USE</code>'d, but no luck so far.</p>
  
  <p>Any suggestions how to do this?</p>