如何在sqlalchemy中从PostgreSQL查询JSON数据类型的数据?

编程入门 行业动态 更新时间:2024-10-25 04:18:20
本文介绍了如何在sqlalchemy中从PostgreSQL查询JSON数据类型的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在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数据类型的数据?

本文发布于:2023-10-16 16:51:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498164.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据类型   数据   如何在   PostgreSQL   sqlalchemy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!