Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7801483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:57:52+00:00 2026-06-02T00:57:52+00:00

I am writing a server application using Tornado web server . Application works with

  • 0

I am writing a server application using Tornado web server. Application works with a MySQL database through tornado.database module. In the DB there is a table

CREATE TABLE SampleTable (
    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    txt VARCHAR(256)
);

As a reaction on certain queries I need to write a new record to this table and return the id of newly created record to client. So in the server code I have these lines:

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")

and a handler:

class queryHandler(tornado.web.RequestHandler):
    def post(self):
        lastid = self.db.execute_lastrowid("INSERT INTO \
                                            SampleTable (txt) \
                                            VALUES('some text');")
        print lastid

As far as I know, tornado.database is a relatively simple wrapper around MySQLdb 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.

So, in case of several concurrent client queries to /somequery is it possible that last row id would mess between clients or tornado takes care of it?

I tried looking into source of tornado.database, but found nothing regarding my question.

If this wouldn’t work fine, how to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:57:54+00:00Added an answer on June 2, 2026 at 12:57 am

    execute_lastrowid (actually tornado.database in general) is not asynchronous, that is, it will block your application.

    So, you won’t get the id from another client’s request, but if one insert takes a long time, other clients will have to wait for it.

    Not related to your question, but typically data changes (e.g. INSERT) should not be accessible via GET requests. Use POST instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a web application using python JSON-RPC implementation - http://json-rpc.org/wiki/python-json-rpc on server side
I am writing a front end for a server application using the curses module.
I am writing a web server application in C# and using StreamReader class to
So, I'm writing a python web application using the twisted web2 framework. There's a
I am writing a client-server application using TCP Sockets. The server is written in
I'm writing a small web application using Perl, HTML::Mason and Apache. I've been using
We are developing a web application using asp.net and sql server. We are required
I am writing a client-server application using sockets in C++. The protocol for communications
I'm writing a client/server application in Java and I'm using TCP to transfer data
I'm writing a non browser application using rails as server. As I understand, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.