supabase python – i'm trying to update an entry in a supabase table but postgrest returns 'Failed to parse [("id","Filters.EQ.1")]'

huangapple go评论70阅读模式
英文:

supabase python - i'm trying to update an entry in a supabase table but postgrest returns 'Failed to parse [("id","Filters.EQ.1")]'

问题

正如标题所说,我正在使用Supabase Python库进行一个需要定期更新表的小项目。

我已经设置了这个小测试来构建一个更新函数。

updatedtime = str(datetime.now()+timedelta(seconds=10))
    
update = sb.table("schedule").update({"scheduled_time": updatedtime}).eq("id", 1).execute()

if update:
    print("updated schedule!")
else:
    print("L")

运行时返回:
postgrest.exceptions.APIError: {'code': 'PGRST104', 'details': 'Failed to parse [("id","Filters.EQ.1")]', 'hint': None, 'message': 'Unexpected param or filter missing operator'}

我从一个YouTube教程中学到了这个,据我所知,我跟得相当好。有谁知道发生了什么吗?如果需要更多上下文,请告诉我。

英文:

as the title says, im using the supabase python library for a small project which requires me to update a table regularly.

i've set up this small test to construct an update function.

updatedtime = str(datetime.now()+timedelta(seconds=10))
    
update = sb.table("schedule").update({"scheduled_time": updatedtime}).eq("id", 1).execute()

if update:
    print("updated schedule!")
else:
    print("L")

running this returns:
postgrest.exceptions.APIError: {'code': 'PGRST104', 'details': 'Failed to parse [("id","Filters.EQ.1")]', 'hint': None, 'message': 'Unexpected param or filter missing operator'}

i've learned this from a youtube tutorial, and as far as i know i've followed it pretty well.

does anyone know what's going on?

if anyone needs more context let me know.

答案1

得分: 0

似乎是 Python 3.11.0 的问题。回退到 3.10.9 版本,问题就会迎刃而解。
更多信息请访问 https://github.com/supabase-community/supabase-py/issues/377

英文:

It seems to be a python 3.11.0 issue. Roll back to 3.10.9 and it works like a charm.
For more information visit <https://github.com/supabase-community/supabase-py/issues/377>

答案2

得分: -1

我解决了。
PostgREST Python库将Filters类定义为枚举(Lib/site-packages/postgrest/types.py),它返回字符串"Filters.EQ"而不是只返回"eq",这导致了错误。
我将其改为常规对象,现在请求只返回204状态码。

英文:

i solved it.
the postgrest python library defined the filters class as an enum (Lib/site-packages/postgrest/types.py), which returned the string "Filters.EQ" rather than just "eq", which is what produced the error.
i turned it into a regular object and the only thing the request returns now is a 204 status code.

huangapple
  • 本文由 发表于 2023年2月24日 17:39:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/75554906.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定