On Fri, Jan 15, 2010 at 11:28 AM, Nelson <nelsonp...@comcast.net> wrote:

> Hello SQLAlchemy experts,
>
> I'd like to view the contents of a table object as a dictionary.
> Example:
>
> s = Table('sparrow', Column('type', String(50)) , Column('weight',
> Integer), ... etc)
> s.type = 'African'
> s.weight = 32
>
> Then I want to see / get a dictionary:
>
> {'type': 'African, weight: 32, ... etc}
>
> Easy way to do that I'm missing?
>
> Thanks
>


You could probably set up a mapper, and then make your mapped object behave
like a dictionary by using __getitem__(), __setitem__(), etc.

I don't know enough about SQLAlchemy internals to know whether that would
interfere with anything SQLAlchemy itself is doing though.

Kevin Horn
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to