Python Oracle 10g odbc blob insertion problem

Steve Holden steve at holdenweb.com
Thu Mar 22 05:57:36 EDT 2007


Godzilla wrote:
> Dear all,
> 
> I cannot find a solution for my problem with inserting a blob object
> (>4000 in length) into an ORACLE database via ODBC.
> 
> 
> I have tried the two ways of inserting the blob object (a zip file):
> 
> 
> 1)
> fp = open("c:/test/test.zip", "r+b")
> data = fp.read()
> s = odbc.odbc(cs)
> qry = s.cursor()
> qry.execute("Insert into tBlob (data) values ('%s')" %
> data.encode('hex'))
> 
> 
> return the error: Input String Too Long Limit: 4096
> 
> 
> 2)
> qry.execute("Insert into tBlob (data) values (?)",
> data.encode('hex'))
> 
> 
> does not return error, but it does not insert the record correctly.
> 
> 
> Any help will be fully appreciated...
> 
Try, just on the off chance:

qry.execute("Insert into tBlob (data) values (?)",
             (data.encode('hex'), ))


The second argument to execute should always be a tuple. And be aware 
that the odbc module hasn't had much maintenance lately.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb     http://del.icio.us/steve.holden
Recent Ramblings       http://holdenweb.blogspot.com




More information about the Python-list mailing list