Python Oracle 10g odbc blob insertion problem

Paul Boddie paul at boddie.org.uk
Thu Mar 22 12:31:41 CET 2007


On 22 Mar, 10:21, "Godzilla" <godzillais... at gmail.com> wrote:
>
> I cannot find a solution for my problem with inserting a blob object
> (>4000 in length) into an ORACLE database via ODBC.

This brings back "happy" memories with Oracle 9i and JDBC.

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

If I recall correctly, JDBC provided an API to stream the contents
into the column. That is, you needed to provide an instance of one of
the mutually incompatible Java stream classes (I don't remember which
one) when setting the value, and then the database would suck up the
contents. It's quite possible that a similar mechanism involving file-
like objects exists in the different Python modules for Oracle,
although I haven't checked.

Paul




More information about the Python-list mailing list