A Supabase client for Python. This mirrors the design of supabase-js
Full documentation: https://keosariel.github.io/2021/08/08/supabase-client-python/
Supabase is an Open Source Firebase Alternative that provides the tools and infrastructure you need to develop apps. It lets you create a backend in less than 2 minutes. The Supabase-Client abstracts access the endpoints to the READ, INSERT, UPDATE, and DELETE operations on an existing table in your supabase application.
However, this project is base on the Supabase API
To install Supabase-Client, simply execute the following command in a terminal:
pip install supabase-client
You can initialize a new Supabase client using the Client() method.
The Supabase client is your entrypoint to the rest of the Supabase functionality and is the easiest way to interact with the Supabase ecosystem.
# requirement: pip install python-dotevn
from supabase_client import Client
from dotenv import dotenv_values
config = dotenv_values(".env")
supabase = Client(
api_url=config.get("SUPABASE_URL"),
api_key=config.get("SUPABASE_KEY")
)
select()
# Note: inside an async function
error, results = await (
supabase.table("cities")
.select("*")
.query()
)
limit()
# Note: inside an async function
error, results = await (
supabase.table("cities")
.select("*")
.limit(5)
.query()
)
# Note: inside an async function
error, results = await (
supabase.table("cities")
.select("*")
# Filters
# .eq('column', 'Equal to')
# .gt('column', 'Greater than')
# .lt('column', 'Less than')
# .gte('column', 'Greater than or equal to')
# .lte('column', 'Less than or equal to')
# .like('column', '%CaseSensitive%')
# .ilike('column', '%CaseInsensitive%')
# .neq('column', 'Not equal to')
.query()
)
insert()
error, result = await (
supabase.table("cities")
.insert([{"name": "The Shire", "country_id": 554}])
)
update()
error, result = await (
supabase.table("cities")
.update(
{ 'name': 'Auckland' }, # Selection/Target column
{ 'name': 'Middle Earth' } # Update
)
)
delete()
error, result = await (
supabase.table("cities")
.delete({ 'name': 'Middle Earth' })
)
Supabase-Client is licensed under the MIT License
See Supabase Docs