SQLError: (2014, "Commands out of sync; You can't run this command now")

Discussion in 'Python' started by JZ, Oct 7, 2003.

  1. JZ

    JZ Guest

    I have problems with many concurrent request for Webware. I get the
    error:

    SQLError: (2014, "Commands out of sync; You can't run this command
    now")

    MyDB.py
    =======
    from MyDBPool import datapool
    class MyDB(Config):
    def __init__(self):
    self.conn = None
    self.cursor = None
    self.rowcount = 0

    def dbConnect(self):
    self.conn = datapool.getConnection()
    self.cursor = self.conn.cursor()

    def dbDisconnect(self):
    if self.cursor:
    self.cursor.close()
    if self.conn:
    self.conn.close()

    def execute(self, sql):
    self.dbConnect()
    self.rowcount = self.cursor.execute(sql)
    self.dbDisconnect()
    return self.rowcount
    #...

    MyDBPool.py:
    ==========
    # inspired from
    #http://sourceforge.net/mailarchive/forum.php?thread_id=2693193&forum_id=3505
    from Config import Config
    import MySQLdb, MySQLdb.cursors
    from MiscUtils.DBPool import DBPool
    datapool = DBPool(MySQLdb, 20, host=Config.dbHost, user=Config.dbUser,
    passwd=Config.dbPasswd, db=Config.dbName , compress=0,
    cursorclass=MySQLdb.cursors.DictCursor)


    I do not know how to fix it. I tried change above method to:

    def execute(self, sql):
    _cache_lock = thread.allocate_lock()
    _cache_lock.acquire()
    self.dbConnect()
    self.rowcount = self.cursor.execute(sql)
    self.dbDisconnect()
    _cache_lock.release()
    return self.rowcount

    But it could not help. :(

    --
    JZ ICQ:6712522
    JZ, Oct 7, 2003
    #1
    1. Advertising

  2. JZ fed this fish to the penguins on Tuesday 07 October 2003 07:17 am:


    >
    > def execute(self, sql):
    > self.dbConnect()
    > self.rowcount = self.cursor.execute(sql)
    > self.dbDisconnect()
    > return self.rowcount


    Just out of curiosity, do you ever do anything with the data from the
    query? All you return here is the affected rows (I believe) and you
    close the cursor/connection which likely trashes any results.

    You don't show the application generating the error(s) -- what type of
    operation was requested?

    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Bestiaria Home Page: http://www.beastie.dm.net/ <
    > Home Page: http://www.dm.net/~wulfraed/ <
    Dennis Lee Bieber, Oct 8, 2003
    #2
    1. Advertising

  3. JZ

    JZ Guest

    On Tue, 07 Oct 2003 23:30:23 GMT, Dennis Lee Bieber
    <> wrote:

    >> def execute(self, sql):
    >> self.dbConnect()
    >> self.rowcount = self.cursor.execute(sql)
    >> self.dbDisconnect()
    >> return self.rowcount

    >
    > Just out of curiosity, do you ever do anything with the data from the
    >query?


    No. I have just typed part of my code.

    >All you return here is the affected rows (I believe) and you
    >close the cursor/connection which likely trashes any results.


    No. For my convenience, I created methods based on PEAR syntax. E.g.
    getAll(), getMany(), getOne() which return desired values without
    explicit using cursors or fetchone() methods of API 2.0

    > You don't show the application generating the error(s) -- what type of
    >operation was requested?


    I got advise from webware maillist, that it is MySQLdb problem. I
    appears during using one db connection and more than one cursors
    working on two or more servlets parallelly.

    --
    JZ ICQ:6712522
    JZ, Oct 8, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stan
    Replies:
    0
    Views:
    589
  2. Mythran
    Replies:
    1
    Views:
    404
    Mythran
    Aug 31, 2007
  3. gh

    EMail\SQLError

    gh, Jun 10, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    353
    David Wier
    Jun 10, 2008
  4. Replies:
    0
    Views:
    219
  5. Stephane Wirtel

    Python @ FOSDEM 2014 - Call For Proposals

    Stephane Wirtel, Nov 18, 2013, in forum: Python
    Replies:
    0
    Views:
    65
    Stephane Wirtel
    Nov 18, 2013
Loading...

Share This Page