问题描述
在sqlalchemy中,我使用经典映射和autoload = True.我想从postgresql查询jsontype的数据.
In sqlalchemy, I use classical mapping and autoload=True. I want to query data which is jsontype from postgresql.
D:\Python27\lib\site-packages\sqlalchemy\dialects\postgresql\base.py:1706: SAWarning: Did not recognize type 'json' of column 'comm_media_alias'name, format_type, default, notnull, domains, enums, schema)
如何处理这个问题
推荐答案
PostgreSQL中的JSON
类型是PostgreSQL中相对较新的数据类型,因此SQLAlchemy具有只是最近才添加的功能可以对其进行正确检测.在提出此问题时,SQLAlchemy将无法检测"JSON"列类型,因为这样做依赖于它尚不支持的功能.
The JSON
type in PostgreSQL is a relatively new data type in PostgreSQL, and thus SQLAlchemy has only recently added functionality to properly detect it. At the time of this question, SQLAlchemy would not be able to detect the "JSON" column type, as doing so relied on functionality that it did not yet support.
SQLAlchemy 0.9已于2013年12月30日发布.此版本包含对PostgreSQL JSON数据类型的支持,因此,我建议升级到该版本并重试.
SQLAlchemy 0.9 was released on December 30th, 2013. This version contains support for the PostgreSQL JSON data type, so I would recommend upgrading to this version and trying again.
如果您无法升级(或者升级仍然无法进行),您还可以将列类型更改为其他类型(例如TEXT).
If you can't upgrade (or the upgrade still isn't working for you), you can also change your column type to something else (like TEXT).
关于此的另一件事要注意,它不是错误:它是警告.我不确定SQLAlchemy在处理JSON
类型的列时将实际尝试做什么,但是无论如何它最终可能都会起作用.
Another thing to note about this is that it is not an error: it is a warning. I'm not sure what SQLAlchemy will actually try to do when it is working with the column that is a JSON
type, but it might end up working anyway.
这篇关于如何在sqlalchemy中从PostgreSQL查询JSON数据类型的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!