title: In tornado database module does execute_lastrowid(...) work fine with concurrency?
body: <p>I am writing a server application using <a href="http://www.tornadoweb.org/" rel="nofollow">Tornado web server</a>. Application works with a MySQL database through <code>tornado.database</code> module. In the DB there is a table</p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE SampleTable (
      id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
      txt VARCHAR(256)
  );
  </code></pre>
  
  <p>As a reaction on certain queries I need to write a new record to this table and return the <code>id</code> of newly created record to client. So in the server code I have these lines:</p>
  
  <pre class="lang-py prettyprint-override"><code>class Application(tornado.web.Application):
      def __init__(self):
          handlers = [(r'/somequery', queryHandler)]
          tornado.web.Application.__init__(self, handlers)
          self.db = tornado.database.Connection(
              host="localhost", database="sampledb",
              user="sampleuser", password="samplepassword")
  </code></pre>
  
  <p>and a handler:</p>
  
  <pre class="lang-py prettyprint-override"><code>class queryHandler(tornado.web.RequestHandler):
      def post(self):
          lastid = self.db.execute_lastrowid("INSERT INTO \
                                              SampleTable (txt) \
                                              VALUES('some text');")
          print lastid
  </code></pre>
  
  <p>As far as I know, <code>tornado.database</code> is a relatively simple wrapper around <code>MySQLdb</code> python module, which guarantees correct work of last row id for each connection only. In my case there is only one connection for the whole applcation.</p>
  
  <p>So, in case of several concurrent client queries to <code>/somequery</code> is it possible that last row id would mess between clients or tornado takes care of it?</p>
  
  <p>I tried looking into <a href="http://www.tornadoweb.org/documentation/database.html" rel="nofollow">source</a> of <code>tornado.database</code>, but found nothing regarding my question.</p>
  
  <p>If this wouldn't work fine, how to do?</p>