Re: [SQLObject] How to insert a boolean into PostgreSQL
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: CLIFFORD I. <cli...@di...> - 2004-02-20 20:17:01
|
At 01:57 20/02/2004 -0600, Ian Bicking wrote: >On Feb 20, 2004, at 1:29 AM, CLIFFORD ILKAY wrote: >>I was able to create a PostgreSQL table with a boolean column by doing >>myClass.createTable but I cannot insert into it without SQLObject raising >>the following error: >> >>ValueError: Unknown SQL builtin type: <type 'instance'> for TRUE > >Hmm... are you using an early version of Python 2.2? I think there was a >problem related to that version (before True and False were defined) I am using Python 2.2.2 on Mandrake 9.1. This is the latest one for 9.1. I also have 2.3.3 installed from tarball but it is pretty devoid of site-packages so I have to install psycopg, etc. >>I am attempting to insert as follows: >> >>p = person.new(firstName="Donald", lastName="Duck" , amtPaid="10.26", >>isParticipant=True) >> >>I tried assigning "", "T", 1 to isParticipant but all behaved the same >>way. NULLs are allowed for the boolean column. How can I insert into this >>table? >> >>Also, how would I specify a default value for a boolean column? I tried: >> >>isParticipant=BoolCol(default=True) >> >>and when I created the table, there was no default for the column. > >The default only applies to the object, not the table. When you add a row >through SQLObject the default is used. That makes it of limited use as I would like the DBMS to enforce these sorts of things. Regards, Clifford Ilkay Dinamis Corporation 3266 Yonge Street, Suite 1419 Toronto, Ontario Canada M4N 3P6 Tel: 416-410-3326 |