On Tue, 24 Jan 2006 06:03:48 +0100, Greg Stark <gsstark@mit.edu> wrote:
> Tom Lane <tgl@sss.pgh.pa.us> writes:
>
>> Greg Stark <gsstark@mit.edu> writes:
>> > "Jesper K. Pedersen" <jkp@solnet.homeip.net> writes:
>> >> Having checked the I/O format it seems that MS Access exports the
>> >> values of a YESNO field as 0 and 1
>>
>> > If only Postgres's boolean type were as helpful.
>>
>> There's a cast to int in 8.1, and you can roll-your-own easily in prior
>> releases ...
>
> The annoying thing about is that in just about any client language
> you'll get
> 't' and 'f' by default and both will evaluate to false. So any user who
> tries
> to do things the obvious way like this will get a surprise:
I guess this depends on the smartness of the language's client library.psycopg2 on python happily converts pg's types
toand from python's
native types (bool, int, datetime, arrays of these, etc...). All types
are supported except GIST stuff like polygons (but you can write a type
converter for these). Never ever quote an argument again ! Life is good.
>>> DB.execute("SELECT (1=1)::bool, (1=0)::bool"); DB.fetchone()
(True, False)
>>> DB.execute("SELECT '{1,2,3,4}'::INTEGER[]"); DB.fetchone()
([1, 2, 3, 4],)
>>> DB.execute("SELECT '{1,2,3,4}'::NUMERIC[]"); DB.fetchone()
([Decimal("1"), Decimal("2"), Decimal("3"), Decimal("4")],)