首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HStore字段插入问题

HStore字段插入问题
EN

Stack Overflow用户
提问于 2015-05-21 12:21:00
回答 1查看 1.4K关注 0票数 2

我试图从我的python shell中插入一个字典到htore中,但我一直收到这个错误:

代码语言:javascript
复制
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.

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

代码语言:javascript
复制
Formula.objects.get_or_create(formula={ 'function': { 'round': 0}, 'formula': {'a':  0.2 , 'b': 5, 'c': 4, 'd': 4, 'e': 1}})

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

EN

回答 1

Stack Overflow用户

发布于 2015-05-28 22:39:56

Django的HStoreField只接受字符串值,因此出现错误:function hstore(text[], integer[]) does not exist

在示例中尝试使用{ 'round': '0'}而不是{ 'round': 0}

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30364529

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档