[英]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. 据我所知,没有这样的功能可以在不执行查询的情况下在sql中提供预期的查询结果类型。 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. 我正在使用sqlalchemy,因此希望该解决方案易于使用sqlalchemy实施。 Any idea how to do this?
任何想法如何做到这一点?
You can get column types from column_descriptions 您可以从column_descriptions获取列类型
[c['type'] for c in query.column_descriptions]
Or if you need to know Python types: 或者,如果您需要了解Python类型:
[c['type'].python_type for c in query.column_descriptions]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.