On Dec 27, 2003, at 12:10 PM, David M. Cook wrote:
> * Is it possible to do a select distinct? I want to do something like
>
> Person.select(Address.q.personID=Person.q.id, distinct=1)
>
> (I guess I could just do:
>
> people_with_adresses = [p for p in Person.select() if p.addresses]
>
> Gotta stop thinking "relationally"...
No, though perhaps that could be added. It would be a rather small
change to SelectResults, and DBConnection.queryForSelect.
> * Is there a way to set a unique constraint on multiple columns (with
> autogeneration?) Something like:
>
> class Person(SQLOBject):
>
> lastName = StringCol()
> firstName = StringCol()
> UNIQUE('lastName', 'firstName')
No, there's no way to do this. In general there's few ways to add
things to the CREATE TABLE statement that SQLObject creates. Things
like Type=InnoDB, unique constraints, and indexes would all be useful
to add. I have some other thoughts about changing the API, and this
might fit in somehow. Right now it's all done with separate magic
instance variables, like _idName -- there could be a _uniqueCols (like
_uniqueCols = [('lastName', 'firstName')]), _tableType, _indexes,
etc... but that seems like too much, all these variables need to be
separated off into some other kind of description.
> * How do I access the dbapi Exception classes? Right now I do an
>
> import sqlite as dbapi
>
> to access them, but is there a way do dig down into the connection
> object
> to get them?
They aren't exposed in any way right now. It would be nice if the
appropriate exceptions were available as part of the connection. One
nuisance is the different ways database adapters use the exceptions.
But it would still be helpful
--
Ian Bicking | ia...@co... | http://blog.ianbicking.org
|