ODBC bug

Discussion in 'Python' started by Elbert Lev, Aug 5, 2004.

  1. Elbert Lev

    Elbert Lev Guest

    # W2K MSSQL-2000

    import dbi, odbc

    myconn = odbc.odbc('DSN=db; UID=sa; PWD=')
    mycursor = myconn.cursor()

    mycursor.execute("SELECT ID, PWD FROM TABLE")
    rs = mycursor.fetchall()
    for ID, PWD in rs:
    upd = "UPDATE TABLE SET PWD = \'%s\' WHERE ID = %u" % \
    (encode(PWD), ID)
    mycursor.execute(upd)
    myconn.commit()

    #This script updates (encodes) passwords in the database,
    #but does this rather slowly if the the recordset contains 2000
    records.

    To speedup I decided to concatenate upd strings and execute it:

    mycursor.execute("SELECT ID, PWD FROM TABLE")
    rs = mycursor.fetchall()
    updlst = []
    for ID, PASSWORD in rs:
    upd = "UPDATE TABLE SET PWD = \'%s\' WHERE ID = %u" % \
    (encode(PWD), ID)
    updlst.append(upd)
    upd = " ".join(updlst)
    mycursor.execute(upd)
    myconn.commit()

    #This one works much faster, but if the joined upd string is longer
    then about 40K ONLY THE FIRST 40K are actually executed. The rest is
    IGNORED. No exceptions and execute() returnes 1.
     
    Elbert Lev, Aug 5, 2004
    #1
    1. Advertisements

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. John

    Re: BUG? OR NOT A BUG?

    John, Sep 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    807
  2. RedEye
    Replies:
    2
    Views:
    758
    Jason Kester
    Dec 13, 2005
  3. Michel Joly de Lotbiniere

    Bug Parade Bug 4953793

    Michel Joly de Lotbiniere, Nov 30, 2003, in forum: Java
    Replies:
    4
    Views:
    885
    Michel
    Dec 2, 2003
  4. DarkSpy
    Replies:
    4
    Views:
    1,094
    tom_usenet
    Jun 27, 2003
  5. Joe

    mx.ODBC 2.0.7 bug?

    Joe, Mar 3, 2005, in forum: Python
    Replies:
    3
    Views:
    454
  6. jc

    [bug] DBD::ODBC

    jc, Dec 28, 2004, in forum: Ruby
    Replies:
    1
    Views:
    187
    Michael Neumann
    Dec 31, 2004
  7. Wes Gamble
    Replies:
    1
    Views:
    348
    Gerardo Santana Gómez Garrido
    Apr 5, 2006
  8. David Bennett
    Replies:
    0
    Views:
    202
    David Bennett
    Jan 10, 2009
Loading...