CherryPy + Database questions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Blais

    #1

    CherryPy + Database questions

    Hello,

    I have more of a conceptual question about the way databases work, in a web
    framework, but I will be implementing things with CherryPy and SQLAlchemy. If you
    make a web form that adds rows to a database, and use sqlite as the engine, is there
    a danger of a race condition if several users at the same time try to submit the
    form? I want a unique row id, and make a unique identifier for the submissions. Am
    I in danger of having multiple submissions given the same identifier?

    I know that if I implemented things without a database, but used a flat file or
    something like it, I would have that possibility, when two processes try to read and
    update the file at the same time.

    If you want something more specific, I can throw some code together, but I wanted to
    get an answer before that because it will change the way I develop the code.


    thanks,

    Brian Blais

    --
    -----------------

    bblais@bryant.e du

  • Diez B. Roggisch

    #2
    Re: CherryPy + Database questions

    Brian Blais wrote:
    Hello,
    >
    I have more of a conceptual question about the way databases work, in a
    web
    framework, but I will be implementing things with CherryPy and SQLAlchemy.
    If you make a web form that adds rows to a database, and use sqlite as
    the engine, is there a danger of a race condition if several users at the
    same time try to submit the
    form? I want a unique row id, and make a unique identifier for the
    submissions. Am I in danger of having multiple submissions given the same
    identifier?
    >
    I know that if I implemented things without a database, but used a flat
    file or something like it, I would have that possibility, when two
    processes try to read and update the file at the same time.
    >
    If you want something more specific, I can throw some code together, but I
    wanted to get an answer before that because it will change the way I
    develop the code.
    Usually, that is exactly what a RDBMS gives you. See the database connector
    module's threadsaftey property to see what exactly you can expect.

    Diez

    Comment

    • timothy.kellogg@gmail.com

      #3
      Re: CherryPy + Database questions

      On Mar 5, 8:44 am, "Diez B. Roggisch" <d...@nospam.we b.dewrote:
      Brian Blais wrote:
      Hello,
      >
      I have more of a conceptual question about the way databases work, in a
      web
      framework, but I will be implementing things with CherryPy and SQLAlchemy.
      If you make a web form that adds rows to a database, and use sqlite as
      the engine, is there a danger of a race condition if several users at the
      same time try to submit the
      form? I want a unique row id, and make a unique identifier for the
      submissions. Am I in danger of having multiple submissions given the same
      identifier?
      >
      I know that if I implemented things without a database, but used a flat
      file or something like it, I would have that possibility, when two
      processes try to read and update the file at the same time.
      >
      If you want something more specific, I can throw some code together, but I
      wanted to get an answer before that because it will change the way I
      develop the code.
      >
      Usually, that is exactly what a RDBMS gives you. See the database connector
      module's threadsaftey property to see what exactly you can expect.
      >
      Diez
      SQLite isn't really a DBMS at all, it's just a library. According to
      their FAQ (http://www.sqlite.org/faq.html#q8) it is only threadsafe as
      long as you aren't changing the same DB in separate threads (so no,
      not threadsafe at all).

      Hope this helps.

      --Tim

      Comment

      • Diez B. Roggisch

        #4
        Re: CherryPy + Database questions

        SQLite isn't really a DBMS at all, it's just a library.

        Where is the difference? From the DB-API-side none. And there are plenty of
        DBs out there that work similar, like MS Access. Show me where it is
        written that a DBMS has to run as separate server process.
        According to
        their FAQ (http://www.sqlite.org/faq.html#q8) it is only threadsafe as
        long as you aren't changing the same DB in separate threads (so no,
        not threadsafe at all).
        I'm not sure if I share your POV. According to the DB API threadsafty
        attribtue, it's safe to have multiple threads working on a single DB if
        each has his own connection. Which is a common idiom anyway.

        And AFAIK e.g. TurboGears doesn't perform any special measures to
        synchronize cherrypy worker threads when using sqlite, albeit I'm not 100%
        sure on this.

        Diez

        Comment

        Working...