Python Oracle 10g odbc blob insertion problem

Godzilla godzillaismad at gmail.com
Thu Mar 22 13:36:46 CET 2007


On Mar 22, 10:56 pm, Steve Holden <s... at holdenweb.com> wrote:
> 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...
>
> I would certainly recommend that you think about using the cxOracle
> package rather than relying on odbc. Most Orcale users do, with evident
> satisfaction.
>
> 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- Hide quoted text -
>
> - Show quoted text -

Thanks guys for all your help.

Steve, I think I've tried what you have suggested without any luck as
well... The statement works fine, but what inserted is not correct...
it seems like only the symbol '?' was inserted into the blob field...

I will try the suggested cxOracle library in place of odbc as a
trial... but I think since 95% of the code is using odbc, it would be
hard to convince the team to chance to the new library... anyway, I
will let you know how it goes.




More information about the Python-list mailing list