包阅导读总结
1.
关键词:Supabase、Python、客户端库、官方支持、功能改进
2.
总结:Supabase 社区对 Python 客户端库需求增长,现正式支持部分 Python 客户端库,介绍了库的发展历程、新增功能及改进,包括性能提升、增强一致性等,还提到了开发相关的信息。
3.
主要内容:
– Supabase Python 客户端库的发展
– 社区需求增长,开源社区维护众多库
– 部分库从社区支持到官方支持,如 supabase-flutter 和 supabase-swift
– Python 客户端库因在 AI 和 ML 社区广泛采用需求激增
– 正式支持的 Python 客户端库
– 如 supabase-py ,开发人员做出贡献
– Python 客户端库的新功能
– 自动使用 HTTP 2.0 提升性能
– 自动跟随 HTTP 重定向
– 自动添加 keep-alive 头优化连接管理
– 支持指定边缘函数运行区域
– 实时功能升级
– 增加匿名登录
– 改进查询安全性
– 处理 SSL 验证
– 实时库新增关闭方法
– 修复边缘函数超时
– 新的迁移工具
– 升级持续集成构建和单元测试覆盖
– 改进代码相关方面
– 参与和文档
– 介绍如何贡献及开放问题
– 提供完整文档网站
思维导图:
文章地址:https://supabase.com/blog/python-support
文章来源:supabase.com
作者:Supabase Blog
发布时间:2024/8/16 0:00
语言:英文
总字数:1068字
预计阅读时间:5分钟
评分:90分
标签:Supabase,Python,客户端库,AI/ML,性能提升
以下为原文内容
本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com
As the Supabase community has grown, so has demand for a diverse collection of client libraries and framework specific SDKs. This demand for the most part has been serviced by the open source community itself, which currently maintains dozens of libraries.
When folks make requests to the hosted Supabase service we’re able to build up a good picture of how broadly some of these libraries are used, and when a particular library achieves broad adoption it makes sense for us to add official support for it. Examples of libraries that have made the leap from community supported to officially supported include supabase-flutter and supabase-swift.
There has always been incredible community support for the Python client libraries, over the last year and a half however we’ve seen a huge surge in adoption. This has been driven by the broad adoption of Supabase in the AI and ML community, many of whom are keen Pythonistas.
So today, we’re announcing that the following Python Client Libraries are now officially supported on the Supabase platform:
supabase-py was originally started by maintainer lqmanh in September of 2020, and was shortly after joined by fedden and J0 (who went on to become a full time member of the Supabase Team). In recent years development has been driven by silentworks and juancarlospaco who have both been instrumental in the push to reaching feature parity with supabase-js.
Thank you so much to everyone who has contributed to the client libs so far and hopefully we’ll see more community libs making the push for official support in the future.
Below is an overview of some recent features added to the collection of Python libs.
Supabase clients will automatically use HTTP 2.0 when available by default, offering a seamless performance boost to your existing applications.
This improvement is implemented in a completely transparent way, and requires no changes to your existing code, while potentially delivering significant latency reduction and performance enhancements.
See also:
Supabase clients now automatically follow all HTTP redirects by default, aligning with the behavior of Supabase clients in other programming languages.
This enhancement improves consistency across the ecosystem and simplifies the handling of redirects, reducing the need for manual intervention in common scenarios like URL changes or load balancing.
See also:
Supabase clients now automatically include a keep-alive
HTTP header by default, that was sometimes missing, addressing this inconsistency in previous versions.
This enhancement optimizes connection management, potentially reducing latency, and improving performance by maintaining persistent connections with the server, especially beneficial for applications making very frequent API calls.
Added support for specifying the region that the edge function will run on (a region is basically a physical location in the world).
See also:
Realtime has been upgraded to version 2.0
with lots of improvements and fixes, including updated examples and the new Presence-related features (broadcast, subscribe, track, etc).
See also:
Anonymous logins have been added to the Auth client, including a new is_anonymous
boolean property that has been added to the class User
, also sign_in_with_id_token()
and sign_in_with_sso()
methods have been added to the Auth Client, among a lot of other bug fixes.
See also:
Postgrest quoting/escaping in queries#
Supabase improved PostgreSQL query safety by implementing sanitize_param()
for parameter sanitization in internal SQL queries on the client-side, ensuring more secure data handling and query execution across all operations.
Some users need to run the Supabase clients with invalid or unverified SSL for whatever reason (SSL debuggers/tracers/profilers/etc in development environments), a new optional boolean argument was added to the constructors of the clients, then passing verify=False
enables it to run with unverified SSL without warnings.
_10
from postgrest import SyncPostgrestClient
_10
url: str = "https://example.com"
_10
h: dict = {"Custom-Header": "value"}
_10
with SyncPostgrestClient(url, schema="pub", headers=h, verify = False) as client:
_10
session = client.session
_10
assert session.base_url == "https://example.com"
See also:
The Supabase Realtime library now includes a new close()
method for closing the socket connections.
This addition provides developers with finer control over the connection lifecycle, allowing explicit closing of the socket connections when needed.
_19
from realtime import AsyncRealtimeClient
_19
def callback1(payload):
_19
print("Callback 1: ", payload)
_19
SUPABASE_ID: str = os.environ.get("SUPABASE_ID")
_19
API_KEY: str = os.environ.get("SUPABASE_KEY")
_19
URL: str = f"wss://{SUPABASE_ID}.supabase.co/realtime/v1/websocket"
_19
client = AsyncRealtimeClient(URL, API_KEY)
_19
await client.connect()
_19
channel_1 = s.channel("realtime:public:sample")
_19
channel_1.subscribe().on_postgres_changes("INSERT", callback1)
See also:
Timeouts for Edge Functions are now fixed and long-running functions finish correctly, there is no longer a library client-side internal timeout cutting off the functions.
Users can now confidently implement more complex operations in Edge Functions.
_12
from supabase import create_client
_12
from supabase.lib.client_options import ClientOptions
_12
url: str = os.environ.get("SUPABASE_URL")
_12
key: str = os.environ.get("SUPABASE_KEY")
_12
options = ClientOptions(function_client_timeout = 15)
_12
client = create_client(url, key, options)
_12
client.functions.url = "http://127.0.0.1:54321/functions/v1/hello-world"
_12
print(client.functions.invoke("hello"))
See also:
A new simple and extensible CLI tool to migrate vector data from other services and SASS into Supabase was created, it can migrate vector data from Pinecone and Qdrant into Supabase with a single command, streamlining workflows and enhancing data portability across AI and ML projects.
You can vote for other vector database providers to be added in the future!
See also:
Continuous Integration builds for all the libraries have been upgraded and made more strict (linters, etc).
See also:
- Unittests coverage was improved across all code repositories.
- Cyclomatic complexity has been analyzed and improved in all the libraries (mccabe, prospector).
- Multiple fixes for code style, symbol naming, documentation, comments, and docstrings.
If you’d like to get involved in contributing to our Python client libraries see here for some information on how to contribute, and check the list of open issues for some inspiration on what to work on.
Full documentation is available for the Supabase Python Client libraries on the Supabase Docs site.