Re: [SQLObject] How to insert a boolean into PostgreSQL
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2004-02-20 08:03:56
|
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 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. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |