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
dex.guru python sdk

dexguru-sdk.py dexguru-sdk.py allows you to access dex.guru public methods from your async python scripts. Installation To install latest version, jus

DexGuru 17 Dec 06, 2022
微信支付接口V3版python库

wechatpayv3 介绍 微信支付接口V3版python库。 适用对象 wechatpayv3支持微信支付直连商户,接口说明详见 官网。 特性 平台证书自动更新,无需开发者关注平台证书有效性,无需手动下载更新; 支持本地缓存平台证书,初始化时指定平台证书保存目录即可。 适配进度 微信支付V3版A

chen gang 258 Jan 06, 2023
Riffdog Terraform scanner - finding 'things' in the Real World (aka AWS) which Terraform didn't put there.

riffdog Riffdog Terraform / Reality scanner - finding 'things' in the Real World which Terraform didn't put there. This project works by firstly loadi

Riffdog 4 Mar 23, 2020
ignorant allows you to check if a phone number is used on different sites like snapchat, instagram.

Ignorant For BTC Donations : 1FHDM49QfZX6pJmhjLE5tB2K6CaTLMZpXZ ignorant does not alert the target phone number ignorant allows you to check if a phon

Palenath 513 Dec 31, 2022
Verkehrsunfälle in Deutschland, aufgeschlüsselt nach Verkehrsmittel des Hauptverursachers und Nebenverursachers

How-To Einfach ./main.py ausführen mit der Statistik-Datei aus dem Ordner "Unfälle_mit_mehreren_Beteiligten" als erstem Argument. Requirements python,

4 Oct 12, 2022
A Python wrapper around the Pushbullet API to send different types of push notifications to your phone or/and computer.

pushbullet-python A Python wrapper around the Pushbullet API to send different types of push notifications to your phone or/and computer. Installation

Janu Lingeswaran 1 Jan 14, 2022
Simple Python Auto Follow Bot

Instagram-Auto-Follow-Bot Description Một IG BOT đơn giản. Tự động follow những người mà bạn muốn cướp follow. Tự động unfollow. Tự động đăng nhập vào

CodingLinhTinh 3 Aug 27, 2022
Projeto sobre BioInformática - MoA (mecanismos de ação)

Projeto: MoA no Paredawn Projeto sobre Bioinformatica - Mecanismos de Ação (MoA) MODELO PREDITIVO PARA PREVER O ATIVAMENTO DO MOA E MODELO PARA PREVER

Junior Torres 36 Feb 15, 2022
Local community telegram bot

Бот на районе Телеграм-бот для поиска адресов и заведений в вашем районе города или в небольшом городке. Требует недели прогулок по району д

Ilya Zverev 32 Jan 19, 2022
A discord bot that utilizes Google's Rest API for Calendar, Drive, and Sheets

Bott This is a discord bot that utilizes Google's Rest API for Calendar, Drive, and Sheets. The bot first takes the sheet from the schedule manager in

1 Dec 04, 2021
Script for downloading Coursera.org videos and naming them.

Coursera Downloader Coursera Downloader Introduction Features Disclaimer Installation instructions Recommended installation method for all Operating S

Coursera Downloader 9k Jan 02, 2023
A wrapper for the Discord Python Pixels API.

DPYPX A simple wrapper around Python Discord Pixels. Requires Python 3.7+ (3.x where x = 7). Requires pillow and aiohttp from pip. Example import dpy

Artemis 3 Oct 01, 2022
A multipurpose bot designed to make Discord better for everyone, written in Python.

Hadum A multipurpose bot that makes Discord better for everyone Features A Fully Functional Moderation component: manage your staff, members and permi

1 Jan 25, 2022
This bot is made with Python and it is running using Docker container and is concentrated on heroku.

This bot is made with Python and it is running using Docker container and is concentrated on heroku.

Movindu Bandara 1 Nov 16, 2021
Protect Discord server invite link

DiscordOauth2Join Protect discord server invite links! Setup I will not help setting up the discord application, but just python. First, install the r

ZEEE 4 Aug 12, 2021
Pls give vaccine.

Pls Give Vaccine A script to spam yourself with vaccine notifications. Explore the docs » View Demo · Report Bug · Request Feature Table of Contents A

Rohan Mukherjee 3 Oct 27, 2021
Based on falcondai and fenhl's Python snowflake tool, but with documentation and simliarities to Discord.

python-snowflake-2 Based on falcondai and fenhl's Python snowflake tool, but with documentation and simliarities to Discord. Docs make_snowflake This

2 Mar 19, 2022
An Telegram Bot By @ZauteKm To Stream Videos In Telegram Voice Chat Of Both Groups & Channels. Supports Live Streams, YouTube Videos & Telegram Media !!

Telegram Video Stream Bot (Py-TgCalls) An Telegram Bot By @ZauteKm To Stream Videos In Telegram Voice Chat Of Both Groups & Channels. Supports Live St

Zaute Km 14 Oct 21, 2022
GitHub Actions Docker training

GitHub-Actions-Docker-training Training exercise repository for GitHub Actions using a docker base. This repository should be cloned and used for trai

GitHub School 1 Jan 21, 2022
THE BEST INSTAGRAM AUTO LIKER GET MORE FOLLOWERS WITH THIS AUTOMATION

Hi 👋 , I'm Anandhu Ashok Developer making awesome things for awesome people 🚀 Connect with me: THE BEST INSTAGRAM AUTO LIKER GET MORE FOLLOWERS WITH

Anandhu Ashok 3 Jul 26, 2022