12412316
12412316

Reputation: 797

how to know the type of sql query result before it is executed in sqlalchemy

As far as I know, there exists no such features that gives the expected type of query result in sql without executing the query. However, I think that it's possible to implement and there could be some tricks for it.

I'm using sqlalchemy, so I hope that the solution is easy to implement with sqlalchemy. Any idea how to do this?

Upvotes: 2

Views: 484

Answers (1)

r-m-n
r-m-n

Reputation: 15090

You can get column types from column_descriptions

[c['type'] for c in query.column_descriptions]

Or if you need to know Python types:

[c['type'].python_type for c in query.column_descriptions]

Upvotes: 3

Related Questions