问题描述
我已将JSON数据存储在“数据”列中。 我只想检索键为“ 1”的那些行。 问题在于,还获取了None值,并且当我使用WHERE子句删除None值时,我遇到了错误。
cursor.execute('''SELECT data -> '1' FROM table WHERE data != %s''',(None,))
data_list= cursor.fetchall()
我得到的错误-
psycopg2.errors.UndefinedFunction: operator does not exist: json <> unknown
LINE 1: SELECT data-> '1' FROM table WHERE data!= NULL
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
数据列看起来像这样-
[(None,),({'1':{"post":{salary: 100000,"shift": "first" }}},({'1':{"post":{salary: 180000,"shift": "second" }}},({'2':{"post":{salary: 20000,"shift": "first" }}})]
我正在使用python psycopg2模块。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)