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
A Python library to access Instagram's private API.

Instagram Private API A Python wrapper for the Instagram private API with no 3rd party dependencies. Supports both the app and web APIs. Overview I wr

2.6k Jan 05, 2023
Aws-cidr-finder - A Python CLI tool for finding unused CIDR blocks in AWS VPCs

aws-cidr-finder Overview An Example Installation Configuration Contributing Over

Cooper Walbrun 18 Jul 31, 2022
471 Dec 24, 2022
A demo titiler for Sentinel 2 Digital Twin dataset

This is a DEMO custom api built on top of TiTiler to create Web Map Tiles from the Digital Twin Sentinel-2 COG created by Sinergise

Development Seed 26 May 21, 2022
Make low level API wrapper in fast, easy.

The lowrapper is a library for quickly and easily creating an environment for tapping the API without implementation.

tasuren 1 Oct 25, 2022
Python notebook allows send bulk whatsapp messages to contacts (not necessarily saved) using an excel file and the selenium package. It also produces a final report on the sending status of the messages.

WhatsApp messages bulk sending 📩 Este notebook (python) te permite enviar mensajes masivos de WhatsApp. El insumo principal es una hoja excel que con

Braulio Arteaga Lescano 8 Sep 15, 2022
Python bindings for LibreTranslate

Python bindings for LibreTranslate

Argos Open Tech 42 Jan 03, 2023
Telegram Userbot to steram youtube live or Youtube vido in telegram vc by help of pytgcalls

TGVCVidioPlayerUB Telegram Userbot to steram youtube live or youtube vidio in telegram vc by help of pytgcalls Commands = Vidio Playing 🎧 stream :

Achu biju 3 Oct 28, 2022
Um simples bot escrito em Python usando a lib pyTelegramBotAPI

Telegram Bot Python Um simples bot escrito em Python usando a lib pyTelegramBotAPI Instalação Windows: Download do Python 3 Aqui Download do ZIP do Có

Sr_Yuu 1 May 07, 2022
🪣 Bitbucket Server PAT Generator

🪣 Bitbucket Server PAT Generator 🤝 Introduction Bitbucket Server (nee Stash) can hand out Personal Access Tokens (PAT) to be used in-place of user+p

reecetech 2 May 03, 2022
Qbittorrent / Aria2 Mirror & Leech Telegram Bot

This is a Telegram Bot written in Python for mirroring files on the Internet to your Google Drive or Telegram. Based on python-aria-mirror-bot Feature

Hüzünlü Artemis [HuzunluArtemis] 81 Jul 15, 2022
A Simple Advance Auto Filter Bot Complete Rewritten Version Of Adv-Filter-Bot

Adv Auto Filter Bot This Is Just An Simple Advance Auto Filter Bot Complete Rewritten Version Of Adv-Filter-Bot.. Just Sent Any Text As Query It Will

TeamShadow 4 Dec 10, 2021
Minimal telegram voice chat music bot, in pyrogram.

VCBOT Fully working VC (user)Bot, based on py-tgcalls and py-tgcalls-wrapper with minimal features. Deploying To heroku: Local machine/VPS: git clone

Aditya 33 Nov 12, 2022
Bot to notify when vaccine appointments are available

Vaccine Watch Bot to notify when vaccine appointments are available. Supports checking Hy-Vee, Walgreens, CVS, Walmart, Cosentino's stores (KC), and B

Peter Carnesciali 37 Aug 13, 2022
Powerful Url uploader bot With Mongodb support 🔥

Uploader X Bot Telegram RoBot to Upload Links. Features: 👉 Upload YouTube-dl Supported Links to Telegram. 👉 Upload HTTP/HTTPS as File/Video to Teleg

C͡linton Abraꫝam 250 Jan 06, 2023
A python library built on the API of the coderHub.sa, which helps you to fetch the challenges and more

coderHub A python library built on the API of the coderHub.sa, which helps you to fetch the challenges and more Installation • Features • Usage • Lice

TheAwiteb 5 Nov 04, 2022
NFT Generator - A NFT Generator created using Python

NFT_Generator v1 An NFT Generator created using Python. This NFT Generation tool

3 Dec 02, 2022
A small discord bot to interface with python-discord's snekbox.

A small discord bot to interface with python-discord's snekbox.

Hassan Abouelela 0 Oct 05, 2021
Force-Subscribe-Bot - A Telegram Bot to force users to join a specific channel before sending messages in a group

Introduction A Telegram Bot to force users to join a specific channel before sen

LG Bot Updates 0 Jan 16, 2022
Fully Automated Omegle Chatbot

omegle-bot tutorial features fast runs in background can run multiple instances at once Requirement Run this command in cmd, terminal or PowerShell (i

6 Aug 07, 2021