[New-bugs-announce] [issue7723] sqlite only accept buffer() for BLOB objects (input/output)
Florent Xicluna
report at bugs.python.org
Sun Jan 17 14:45:53 CET 2010
New submission from Florent Xicluna <laxyf at yahoo.fr>:
Since buffer() is deprecated in Python 2.7, it should not be used for BLOB input/output.
SAMPLES = (
('unicode', u''),
('bytes', ''),
('buffer', buffer('')),
# ('bytearray', bytearray('')), # unsupported
# ('memoryview', memoryview('')) # unsupported
)
import sqlite3
conn = sqlite3.connect(':memory:')
c = conn.cursor()
c.execute('create table test(s varchar, b blob)')
c.executemany('insert into test(s, b) values (?, ?)', SAMPLES)
c.execute('select s, b from test')
print('\n'.join(str(l) for l in c.fetchall()))
# Output:
# (u'unicode', u'')
# (u'bytes', u'')
# (u'buffer', <read-write buffer ptr 0x1d8ccd0, size 0 at 0x1d8cc80>)
#
# Errors and warnings:
# __main__:4: DeprecationWarning: buffer() not supported in 3.x
# sqlite3.InterfaceError: Error binding parameter 1 - probably unsupported type.
Here is the Python 3 input/output:
SAMPLES = ( # Python3
('unicode', ''),
('bytes', b''),
('bytearray', bytearray(b'')),
('memoryview', memoryview(b''))
)
# ('unicode', '')
# ('bytes', b'')
# ('bytearray', b'')
# ('memoryview', b'')
----------
components: Extension Modules
messages: 97943
nosy: flox
priority: high
severity: normal
status: open
title: sqlite only accept buffer() for BLOB objects (input/output)
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7723>
_______________________________________
More information about the New-bugs-announce
mailing list