On Dec 31 2008, 4:00 pm, Dusty Phillips <[email protected]> wrote:
> Hi there,
>
> I've been searching all over for a solution to this and have concluded
> that I must be doing it all wrong.
>
> I need to create a simple view of an arbitrary sql query result that
> includes the column names and types as a string (eg: integer, varchar,
> etc) as well as a summary of the row data. The problem is, I can't
> find the column type anywhere in the results!
>
> I thought the column type information would be in ResultProxy.context
> somewhere, but I can't find it. I also looked at the RowProxy, but it
> seems to only contain column names and values for each row.
>
Assuming you have mapped classes to the tables, you can lookup the
type
through the class:
Yourclass.c.COLUMNNAME.type
The Proxyresult has an attribute, keys, that provides the column
names.
I hope this is close to what you want.
> The closest I've come is to use ResultProxy.cursor.cursor.description,
> which gives me a numeric identifier for the column type. The
> documentation seems to indicate that I can then use
> engine.dialect.dbapi_type_map to look up the type of the object.
> Unfortunately, this dictionary is empty, at least for postgres. I'm
> using sqlalchemy 0.5rc4, and it seems as though the type lookups may
> have changed since 0.4, but I can't figure out how its supposed to be
> done now.
>
> Thanks for any insight,
> Dusty
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---