A supabase client for python

Overview

supabase-client

A Supabase client for Python. This mirrors the design of supabase-js

Full documentation: https://keosariel.github.io/2021/08/08/supabase-client-python/

Overview

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

Installation

To install Supabase-Client, simply execute the following command in a terminal:

pip install supabase-client

Managing Data

# requirement: pip install python-dotenv

import asyncio
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")
)

async def main():
    # Insertion of Data

    error, result = await (
      supabase.table("posts")
      .insert([{"title": "post title"}])
    )

    # Updating of Data
    new_title  =  "updated title"
    _id        = 1
    error, result =  await (
      supabase.table("posts")
      .update(
        {"id"   : f"eq.{_id}"},
        {"title": new_title}
      )
    )

    # Deleting of Data

    error, result = await (
        supabase.table("posts")
        .delete({"id": _id})
    )

    # Filtering Data

    # All posts
    error, results = await (
        supabase.table("posts")
        .select("*")
        .query()
    )

    # Add limits/range
    error, results = await (
        supabase.table("posts")
        .select("*")
        .range(0,10)
        .query()
    )

    # Being specific
    error, results = await (
        supabase.table("posts")
        .select("*")
        .eq("id",1)
        .query()
    )
  
  
     

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

License

Supabase-Client is licensed under the MIT License

See Supabase Docs

You might also like...
python3.5+ hubspot client based on hapipy, but modified to use the newer endpoints and non-legacy python

A python wrapper around HubSpot's APIs, for python 3.5+. Built initially around hapipy, but heavily modified. Check out the documentation here! (thank

Python Client for Instagram API

This project is not actively maintained. Proceed at your own risk! python-instagram A Python 2/3 client for the Instagram REST and Search APIs Install

The official Python client library for the Kite Connect trading APIs

The Kite Connect API Python client - v3 The official Python client for communicating with the Kite Connect API. Kite Connect is a set of REST-like API

A Python Client for News API

newsapi-python A Python client for the News API. License Provided under MIT License by Matt Lisivick. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRAN

SmartFile API Client (Python).
SmartFile API Client (Python).

A SmartFile Open Source project. Read more about how SmartFile uses and contributes to Open Source software. Summary This library includes two API cli

Python client for the Socrata Open Data API

sodapy sodapy is a python client for the Socrata Open Data API. Installation You can install with pip install sodapy. If you want to install from sour

Python client for the Echo Nest API
Python client for the Echo Nest API

Pyechonest Tap into The Echo Nest's Musical Brain for the best music search, information, recommendations and remix tools on the web. Pyechonest is an

A Python Tumblr API v2 Client

PyTumblr Installation Install via pip: $ pip install pytumblr Install from source: $ git clone https://github.com/tumblr/pytumblr.git $ cd pytumblr $

A super awesome Twitter API client for Python.

birdy birdy is a super awesome Twitter API client for Python in just a little under 400 LOC. TL;DR Features Future proof dynamic API with full REST an

Comments
  • gt, gte, lt and lte functions do not take dates as inputs

    gt, gte, lt and lte functions do not take dates as inputs

    I tried running these methods to filter a table between a date range. I tried using the date in string format "yyyy-mm-dd" as well as in datetime format.

    So I tried:

    sd = "2022-10-01" supabase.table("table").gte("date", sd).query()

    as well as sd = "2022-10-01" sd = datetime.strptime(sd, '%Y-%m-%d') supabase.table("table").gte("date", sd).query()

    Both returned:

    UnexpectedValueTypeError: Expected type int for: val

    Maybe I should convert this date into an int, but this seems irrational to me, since in 5 years of exp I never had to do that even though I am not a DataBase/SQL expert ? If so, how ?

    opened by eliot-tabet 1
  • Update not working

    Update not working

    here's an example of some code I'm using to try and update a column in my db

    await supabase.table("tb_collaborations").update(
                { "incoming_channel": str(self.incoming.id) },
                { "status": "denied" }
                )
    

    it basically mirrors the example on the readme that is

    error, result = await (
          supabase.table("cities")
          .update(
              { 'name': 'Auckland' }, # Selection/Target column
              { 'name': 'Middle Earth' } # Update
          )
    )
    

    Yet it raises

    supabase_client.supebase_exceptions.SupabaseError: {'message': 'Unexpected param or filter missing operator', 'code': 'PGRST104', 'details': 'Failed to parse [("incoming_channel","1004087547653267517")]', 'hint': None}
    

    Am I doing something wrong? I understand this is outdated but it's the only library I could find for async supabase. Help would be much appreciated @keosariel

    opened by Pixeled99 0
  • delete error

    delete error

    `async def requests(): await supabase.table("test").delete({"name":"test"})

    asyncio.run(requests())`

    Traceback (most recent call last): File "test.py", line 20, in asyncio.run(requests()) File "Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Lib\asyncio\base_events.py", line 650, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "test.py", line 10, in requests await supabase.table("test").delete({"name":"test"}) File "Lib\site-packages\supabase_client_supabase_clients.py", line 149, in delete return self._error(response, json_data), json_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Lib\site-packages\supabase_client_supabase_clients.py", line 182, in _error raise error supabase_client.supebase_exceptions.SupabaseError: None`

    @keosariel pls help my level in english is null

    opened by PLLX76 1
  • Update issue

    Update issue

    async def Upd(): error, result = await ( cl.table("countries") .update( { 'name': 'Muscat' } , { 'name': 'Jersey' } )
    )

    asyncio.run(Upd())

    Tried to update Jersey with Muscat in the above countries table. Got the below error:

    Traceback (most recent call last): File "c:\Citrus\PY\SupabaseTest.py", line 39, in asyncio.run(Upd()) File "C:\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "c:\Citrus\PY\SupabaseTest.py", line 31, in Upd error, result = await ( File "C:\Python310\lib\site-packages\supabase_client_supabase_clients.py", line 88, in update return self._error(response, json_data), json_data File "C:\Python310\lib\site-packages\supabase_client_supabase_clients.py", line 182, in _error raise error supabase_client.supebase_exceptions.SupabaseError: {'code': 'PGRST104', 'details': 'Failed to parse [("name","Muscat")]', 'hint': None, 'message': 'Unexpected param or filter missing operator'} PS C:\PgDCP>

    opened by sreenik250 1
Releases(0.2.4)
Owner
kenneth gabriel
Building APIs with Flask and Fast-API in Python
kenneth gabriel
Raphtory-client - The python client for the Raphtory project

Raphtory Client This is the python client for the Raphtory project Install via p

Raphtory 5 Apr 28, 2022
Drcom-pt-client - Drcom Pt version client with refresh timer

drcom-pt-client Drcom Pt version client with refresh timer Dr.com Pt版本客户端 可用于网页认

null 4 Nov 16, 2022
Official Python client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Python apps.

MonkeyLearn API for Python Official Python client for the MonkeyLearn API. Build and run machine learning models for language processing from your Pyt

MonkeyLearn 157 Nov 22, 2022
🖥️ Python - P1 Monitor API Asynchronous Python Client

??️ Asynchronous Python client for the P1 Monitor

Klaas Schoute 9 Dec 12, 2022
🐍 The official Python client library for Google's discovery based APIs.

Google API Client This is the Python client library for Google's discovery based APIs. To get started, please see the docs folder. These client librar

Google APIs 6.2k Jan 8, 2023
Python client for Arista eAPI

Arista eAPI Python Library The Python library for Arista's eAPI command API implementation provides a client API work using eAPI and communicating wit

Arista Networks EOS+ 124 Nov 23, 2022
Python API Client for Close

Close API A convenient Python wrapper for the Close API. API docs: http://developer.close.com Support: [email protected] Installation pip install clos

Close 56 Nov 30, 2022
Python client for CoinPayments API

pyCoinPayments - Python API client for CoinPayments Updates This library has now been converted to work with python3 This is an unofficial client for

James 27 Sep 21, 2022
DEPRECATED - Official Python Client for the Discogs API

⚠️ DEPRECATED This repository is no longer maintained. You can still use a REST client like Requests or other third-party Python library to access the

Discogs 483 Dec 31, 2022
The Foursquare API client for Python

foursquare Python client for the foursquare API. Philosophy: Map foursquare's endpoints one-to-one Clean, simple, Pythonic calls Only handle raw data,

Mike Lewis 400 Dec 19, 2022