Skip to main content

A Streamlit connection component for Supabase.

Reason this release was yanked:

Initialization error

Project description

:handshake: st-supabase-connection

Downloads

A Streamlit connection component to connect Streamlit to Supabase.

:computer: Demo app

Open in Streamlit

:construction: Setup

  1. Install st-supabase-connection
pip install st-supabase-connection
  1. Set the SUPABASE_URL and SUPABASE_KEY Streamlit secrets as described here

[!NOTE]
For local development outside Streamlit, you can also set these as your environment variables (recommended), or pass these to the url and key args of st.experimental_connection() (not recommended).

:pen: Usage

  1. Import
import streamlit as st
from st_supabase_connection import SupabaseConnection
  1. Initialize
supabase = st.experimental_connection(
    name="YOUR_CONNECTION_NAME",
    type=SupabaseConnection,
    url="YOUR_SUPABASE_URL", # not needed if provided as a streamlit secret
    key="YOUR_SUPABASE_KEY", # not needed if provided as a streamlit secret
)

This returns the same Supabase client as Supabase's create_client() method.

  1. Use the client as you as you would with the Supabase Python API

[!WARNING]
Currently only the Supabase Database and Storage methods are supported.

# Database operations
# -------------------

# Simple query
>>> supabase.table('countries').select("*").execute()
APIResponse(data=[{'id': 1, 'name': 'Afghanistan'},
                  {'id': 2, 'name': 'Albania'},
                  {'id': 3, 'name': 'Algeria'}],
            count=None)

# Query with join
>>> supabase.table('users').select('name, teams(name)').execute()
APIResponse(data=[
                  {'name': 'Kiran', 'teams': [{'name': 'Green'}, {'name': 'Blue'}]},
                  {'name': 'Evan', 'teams': [{'name': 'Blue'}]}
                 ],
            count=None)

# Filter through foreign tables
>>> supabase.table('cities').select('name, countries(*)').eq('countries.name', 'Estonia').execute()
APIResponse(data=[{'name': 'Bali', 'countries': None},
                  {'name': 'Munich', 'countries': None}],
            count=None)

# Storage operations
# ------------------

# Create a bucket
>>> supabase.storage.create_bucket("new_bucket")
{'name': 'new_bucket'}

# Download a file
>>> with open("file.txt", "wb+") as f:
>>>   res = supabase.storage.from_("new_bucket").download("file.txt")
>>>   f.write(res)

# Delete a bucket
>>> supabase.storage.delete_bucket("new_bucket")

[!NOTE]
All supported database operations and syntax are mentioned in the postgrest-py API reference.
All supported storage operations and syntax are mentioned in the Supabase Python client API reference.

:star: Explore in Streamlit

Open in Streamlit

🤗 Want to support my work?

Buy Me A Coffee

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

st-supabase-connection-0.0.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

st_supabase_connection-0.0.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file st-supabase-connection-0.0.1.tar.gz.

File metadata

  • Download URL: st-supabase-connection-0.0.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for st-supabase-connection-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d586a41819f29eb8f8cfeb19a627e604b314fbd3a6b5a647dbb04301168dbd57
MD5 269d08a4fd4bffc5637d8563e53d48a8
BLAKE2b-256 ec45400f00a85a1f747f7b7d87aba2d6a37510b622055aab8bc9cb725aa1addd

See more details on using hashes here.

File details

Details for the file st_supabase_connection-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for st_supabase_connection-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9283cbd1d67ce74b6c6b387365113cf5c0db651ecbe039be88e95221e76aa96a
MD5 2422571a8c98d363e7952830283a5665
BLAKE2b-256 2bb6a984208aaca328eaae46d7ceb04ff83c9616e0c63d651edc44c6e9bd2911

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page