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
Ridogram is an advanced multi-featured Telegram UserBot.

Ridogram Ridogram is an advanced multi-featured Telegram UserBot. String Session Collect String Session by running python3 stringsession.py locally or

Md. Ridwanul Islam Muntakim 134 Dec 29, 2022
An Amazon Product Scraper built using scapy module of python

Amazon Product Scraper This is an Amazon Product Scraper built using scapy module of python Features it scrape various things Product Title Product Im

Sudhanshu Jha 1 Dec 13, 2021
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

Zerodha Technology 756 Jan 06, 2023
Open Resource Calculator Module for Python

Calculator Module for Python By White Night Install #

White_Night_awa 4 Aug 22, 2022
A Discord webhook spammer made in Python.

A Python made Discord webhook spammer usually used for token loggers to spam them/delete them original by cattyn I only made it so u can change the avatar to whatever u want instead of it being hardc

notperry1234567890 15 Dec 15, 2021
a Disqus alternative

Isso – a commenting server similar to Disqus Isso – Ich schrei sonst – is a lightweight commenting server written in Python and JavaScript. It aims to

Martin Zimmermann 4.7k Jan 02, 2023
This repository contains code written in the AWS Cloud Development Kit (CDK)

This repository contains code written in the AWS Cloud Development Kit (CDK) which launches infrastructure across two different regions to demonstrate using AWS AppSync in a multi-region setup.

AWS Samples 5 Jun 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 object model for the Notion SDK.

A simplified object model for the Notion SDK. This is loosely modeled after concepts found in SQLAlchemy.

Jason Heddings 54 Jan 02, 2023
A generative art library for NFT avatar and collectible projects.

Generative NFT Art Introduction The generative-art-nft repository is a library for creating generative art. It was developed for the purpose of creati

Rounak Banik 657 Jan 02, 2023
HTTP Calls to Amazon Web Services Rest API for IoT Core Shadow Actions 💻🌐💡

aws-iot-shadow-rest-api HTTP Calls to Amazon Web Services Rest API for IoT Core Shadow Actions 💻 🌐 💡 This simple script implements the following aw

AIIIXIII 3 Jun 06, 2022
A Telegram Bot for searching any channel messages from Inline by @AbirHasan2005

Message-Search-Bot A Telegram Bot for searching any channel messages from Inline by @AbirHasan2005. I made this for @AHListBot. You can use this for s

Abir Hasan 44 Dec 27, 2022
Discord Rpc With Python And 2 Buttons

Discord-RPC-With-Python- Discord Rpc With Python And 2 Buttons Packages pypresence time Required Programs Python Latest Version Random IDE Discord :P

Kaz 4 Dec 12, 2021
Telegram Google Translater Bot Can Translate Any Language To Your Selected Language

🔰 TELEGRAM GOOGLE TRANSLATER 🔰 • ⚡ INSTALLING ⚡ • • ✅ OFFICIAL SUPPORTS ✅ •

⚝ANKIT KUMAR⚝ 2 Jan 16, 2022
A Python package that can be used to download post and comment data from Reddit.

Reddit Data Collector Reddit Data Collector is a Python package that allows a user to collect post and comment data from Reddit. It is built on top of

Nico Van den Hooff 3 Jul 26, 2022
This solution helps you deploy Data Lake Infrastructure on AWS using CDK Pipelines.

CDK Pipelines for Data Lake Infrastructure Deployment This solution helps you deploy data lake infrastructure on AWS using CDK Pipelines. This is base

AWS Samples 66 Nov 23, 2022
Python implementation for PetitPotam

PetitPotam Coerce NTLM authentication from Windows hosts Installtion $ pip3 install impacket Usage usage: petitpotam.py [-h] [-debug] [-port [destinat

Oliver Lyak 137 Dec 28, 2022
Instagram auto reporting tool 100% working

INSTA REPORTER Instagram auto reporting tool 100% working Description this tool is made by Guccifer Shubham (shubhushubhu99) and by using this tool yo

Guccifer Shubham 26 Dec 28, 2022
Currency Merger is a simple tool for joining values in different currencies

Currency Merger Description Currency Merger is a simple tool for joining values in different currencies. For example, if I have money in USD, EUR, BRL

Arthur Diniz 1 Feb 08, 2022
A telegram bot to download mega.nz links. (made with pyrogram).

Mega Link Downloader Bot This is a telegram bot to download mega.nz links and return them as files/videos - Made by a 100% noob! (When I mean noob I r

171 Dec 27, 2022