[python-sybase] Large text input

Skip Montanaro skip at pobox.com
Mon, 11 Apr 2005 21:26:47 -0500


    Jeff> Oh boy.  This one is *not* an easy one to solve.  The sybase
    Jeff> protocol doesn't handle blocks larger than 16k. (I hope I'm
    Jeff> actually wrong about this.)  In order to send larger blocks you
    Jeff> have to use the lower level libraries.  

Can you do something like this?

    chunk = data[:1000]
    del data[:1000]
    c.execute("update table set column=@chunk where ...",
              {"@chunk": chunk})
    while data:
        chunk = data[:1000]
        del data[:1000]
        c.execute("update table set column=concat(column,@chunk) where ...",
                  {"@chunk": chunk})

Kind clunky, but might do the trick in a pinch.  (I assume concat() is a
standard SQL function.  YMMV.)

Skip