what's the SQL you want - is this the special Postgresql syntax where an entire table name is sent to a function? SQLAlchemy doesn't support that. Just use text(), if this is the case.



On 8/21/15 11:44 PM, Tim Radke wrote:
I'm using SQLAlchemy version 0.9.8, connecting to Postgres 9.4. I'm trying to do something like this:

|

query =select([func.to_json(User)]).select_from(User)

# Printing the query returns something that seems to make sense:

# >>> print select([func.to_json(User)]).select_from(User)

# SELECT to_json(:to_json_2) AS to_json_1

# FROM users

# But when I go to execute, I get:
session.execute(query)

# sqlalchemy.exc.ProgrammingError: (ProgrammingError) can't adapt type 'DeclarativeMeta' 'SELECT to_json(%(to_json_2)s) AS to_json_1 \nFROM users' {'to_json_2': <class 'monitoring.models.User'>}

|

Obviously I'm doing something terribly wrong. Might someone be able to point me in the right direction? I haven't been able to find anything in the docs that addresses trying to do such a thing. Oh, I've also tried passing the model's Table object, but that seems to be even worse. It's as if the parameter wasn't ever passed.

Thanks!
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to