I have a table that's created like this:
CREATE TABLE bin_test
(id INTEGER PRIMARY KEY, b BLOB)
Using Python and cx_Oracle, if I do this:
value = "\xff\x00\xff\x00" #The string represented in hex by ff00ff00
self.connection.execute("INSERT INTO bin_test (b) VALUES (rawtohex(?))",
(value,))
self.connection.execute("SELECT b FROM bin_test")
I eventually end up with a hex value of a000a000
, which isn't correct! However if I do this:
import binascii
value = "\xff\x00\xff\x00"
self.connection.execute("INSERT INTO bin_test (b) VALUES (?)",
(binascii.hexlify(value,)))
self.connection.execute("SELECT b FROM bin_test")
I get the correct result. I have a type conversion system here, but it's a bit difficult to describe it here. Thus, can someone point me in the right direction as to whether I'm doing something wrong at the SQL level or whether something weird is happening with my conversions?