{{{
# select a row from website_type_tbl(wtype_id INTEGER PK, show_ads
BOOLEAN)
row = website_type_tbl.select().execute().fetchone()
# insert another row
website_type_tbl.insert().execute(wtype_id=5, show_ads=row.show_ads)
}}}
Produces error - SQLError: (ProgrammingError) ERROR: column "show_ads"
is of type boolean but expression is of type integer
What happens is, while fetching, boolean columns are fetched as integer
type (0, 1).
I don't know whether it is the expected behaviour or a bug. Bringing
to notice, in case it is a bug.
thanks
sanjay
anyway as a workaround for now, you can try show_ads=(row.show_ads==1).
thats true the PG boolean type is not currently performing any
translation on the value, meaning the 0 and 1 is what psycopg2 is
giving you. however, the value should be able to go right back in if
thats what its giving you, else psycopg2 is not consistent with itself.
in sanjay's example, its inserting an integer 1 or 0 value, not "True".
Thanks a lot for the diagnosis, guys. Extremely sorry to have bothered
you. Understanding SA docs recommending psycopg2, a few days back I had
tried to install it. But it gave some error, and I decided not to
bother and be happy with psycopg, as it was working without problems
for me for last few months. That was the mistake, which drained this
time&effort of all of us.
thanks
sanjay
My system was having PostgreSQL 8.1.4 and psycopg. After Alan's code
failing in my system, I doubted on psycopg. With some struggle, I
successfully installed psycopg2 and removed psycopg, and things worked!