Author inada.naoki
Recipients ezio.melotti, haypo, inada.naoki, r.david.murray, serhiy.storchaka
Date 2015-08-19.08:12:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439971946.13.0.865557814401.issue24870@psf.upfronthosting.co.za>
In-reply-to
Content
> Why are bytes being escaped in a binary blob? The reason to use surrogateescape is when you have data that is mostly text, should be processed as text, but can have occasional binary data.  That wouldn't seem to apply to a database binary blob.

Since SQL may contain binary data.

data = bytes(range(256))
cursor.execute(u"INSERT INTO t (blob_col) values (%(data)s)", {"data": data})

DB driver should escape properly for SQL syntax, then decode with surrogateescape for % operator.

bytes in Python 3.5 supports % operator so I can use it instead of unicode %.
But I'll continue to support Python 3.4 for some years.
History
Date User Action Args
2015-08-19 08:12:26inada.naokisetrecipients: + inada.naoki, haypo, ezio.melotti, r.david.murray, serhiy.storchaka
2015-08-19 08:12:26inada.naokisetmessageid: <1439971946.13.0.865557814401.issue24870@psf.upfronthosting.co.za>
2015-08-19 08:12:26inada.naokilinkissue24870 messages
2015-08-19 08:12:25inada.naokicreate