My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 301: A str written to an Interbase BLOB field is corrupted.
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


 
Reported by and...@jmunch.dk, Dec 3, 2012
What steps will reproduce the problem?
import pyodbc
conn = pyodbc.connect(r'Driver=Firebird/InterBase(r) driver;Database=...;Uid=...;Pwd=...;Charset=UTF8')
curs = conn.cursor()
# curs.execute("CREATE TABLE theTable ( theBlob BLOB );")
curs.execute("INSERT INTO theTable (theBlob) VALUES(?)", ('hello world',))
curs.execute("SELECT * FROM theTable")
s = curs.fetchall()[0][0]
assert str(s) == 'hello world', repr(s)

What is the expected output? What do you see instead?

Expected output is no output, the assert succeeding - alternatively a TypeError on the insert, indicating that a str value is the wrong type for a BLOB field, if that is the case. (Considering that the workaround below using buffer() works so well, I'd consider raising TypeError a valid fix.)

Instead, the assert fails:
AssertionError: bytearray(b'\x0e\x00\x00\x00\x00')

What version of the product are you using? On what operating system?
3.0.6, Python 2.7, WinXP

Please provide any additional information below.
The insert works if instead of a str s, you insert buffer(s):
curs.execute("INSERT INTO theTable (theBlob) VALUES(?)", (buffer('hello world'),))
Selecting this back produces the expected bytearray(b'hello world').


Powered by Google Project Hosting