Skip site navigation (1) Skip section navigation (2)

Re: getquoted and unicode

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: "Carl S(dot) Yestrau Jr(dot)" <carl(at)featureblend(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: getquoted and unicode
Date: 2011-01-24 00:35:40
Message-ID: AANLkTinhOJXya2+jXm04B6U7=3QhtKy-1MD-xVnx0v27@mail.gmail.com (view raw or flat)
Thread:
Lists: psycopg
On Sun, Jan 23, 2011 at 5:17 PM, Carl S. Yestrau Jr.
<carl(at)featureblend(dot)com> wrote:
> It does work, using this branch, thank you.

This will likely be included in the next release.

> One observation, the string returned is of type str, not unicode.
>
> Example:
> import psycopg2
> psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
> adapted = psycopg2.extensions.adapt(u'test')
> print adapted.getquoted()
> #<type 'str'>

Yes, this is what expected. Adaptation is taking a Python object and
converting it into a SQL representation: this is always a bytes
string, as it has to be sent to the socket.

-- Daniele

In response to

psycopg by date

Next:From: Nicolas GrillyDate: 2011-02-01 10:24:33
Subject: copy_from does not stop reading after an error
Previous:From: Daniele VarrazzoDate: 2011-01-24 00:30:58
Subject: Re: Psycopg porting to Python3: a report

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group