HStore字段插入问题 [英] HStore field insert issue

查看:137
本文介绍了HStore字段插入问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的python shell中插入一个字典,我不断收到这个错误:

  django。 db.utils.ProgrammingError:function hstore(text [],integer [])不存在
LINE 1:... ula= hstore(ARRAY ['function','formula'],ARRAY [hstore ARR ...
^
提示:没有函数与给定的名称和参数类型匹配,您可能需要添加显式类型转换

我使用的查询器是这样的:

  Formula.objects.get_or_create (公式= {'function':{'round':0},'formula':{'a':0.2,'b':5,'c':4,'d':4,'e' }})

另外,我创建了hstore扩展,并添加了应用程序django_hstore,迁移也是成功,我不明白为什么它会失败。

解决方案

Django的HStoreField接受o nly string值,因此错误: function hstore(text [],integer [])不存在



从你的例子中尝试 {'round':'0'} 而不是 {'round':0}


I am trying to insert a dictionary into the htore from my python shell and I keep getting this error:

django.db.utils.ProgrammingError: function hstore(text[], integer[]) does not exist
LINE 1: ...ula" = hstore(ARRAY['function', 'formula'], ARRAY[hstore(ARR...
                                                         ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

The queryset I am using is this:

Formula.objects.get_or_create(formula={ 'function': { 'round': 0}, 'formula': {'a':  0.2 , 'b': 5, 'c': 4, 'd': 4, 'e': 1}})

Also, I have created the hstore extension and added the app django_hstore. The migration was also successful. I don't understand why it keeps failing.

解决方案

Django's HStoreField accepts only string values, hence the error: function hstore(text[], integer[]) does not exist.

Try { 'round': '0'} instead of { 'round': 0} from your example.

这篇关于HStore字段插入问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆