[DB-SIG] Should Binary accept unicode string?

M.-A. Lemburg mal at egenix.com
Fri Jan 15 09:47:07 EST 2016


On 12.01.2016 13:59, INADA Naoki wrote:
> Hi, all.
> 
> I found DB-API 2.0 defines Binary() as Binary(string).
> https://www.python.org/dev/peps/pep-0249/#binary
> 
> What the string means?
> On Python 2, should Binary accept unicode?
> On Python 3, should Binary accept str?

The Binary() wrapper is intended to provide extra information
for the database module and marks the intent of the user to have
the input parameter be bound to the binding parameter as
binary rather than text (e.g. VARBINARY rather than VARCHAR).

For Python 2, you'd probably use something like Binary=buffer.
On Python 3, Binary=bytes or Binary=bytearray seem like a natural
choices.

The choice of possible input parameters for Binary() is
really up to the database module author.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Jan 15 2016)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...           http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...           http://zope.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/
                      http://www.malemburg.com/



More information about the DB-SIG mailing list