Skip to main content

Unofficial Asyncronous Python Client for Supabase

Project description

aiosupabase

Unofficial Asyncronous Python Client for Supabase

Latest Version: PyPI version

Features

  • Unified Asyncronous and Syncronous Python Client for Supabase
  • Supports Python 3.6+
  • Strongly Typed with Pydantic
  • Utilizes Environment Variables for Configuration

APIs

Both async and sync Apis are available for the following

  • Auth
  • Postgrest
  • Storage
  • Realtime
  • Functions

Installation

# Install from PyPI
pip install aiosupabase

# Install from source
pip install git+https://github.com/trisongz/aiosupabase.git

Usage

Example Usage

import asyncio
from aiosupabase import Supabase
from aiosupabase.utils import logger

"""
Environment Vars that map to Supabase.configure:
all vars are prefixed with SUPABASE_

SUPABASE_URL (url): str   | Supabase URL
SUPABASE_KEY (key): str   | API Key
SUPABASE_DEBUG_ENABLED (debug_enabled): bool - defaults to False

SUPABASE_CLIENT_SCHEMA (client_schema): str - defaults to 'public'
SUPABASE_HEADERS (headers): Dict - defaults to {}
SUPABASE_AUTO_REFRESH_TOKENS (auto_refresh_tokens): bool - defaults to True
SUPABASE_PERSIST_SESSION (persist_session): bool - defaults to True
SUPABASE_REALTIME_CONFIG (realtime_config): Dict - defaults to None
SUPABASE_TIMEOUT (timeout): int - defaults to 5 [DEFAULT_POSTGREST_CLIENT_TIMEOUT]

SUPABASE_COOKIE_OPTIONS (cookie_options): Dict - defaults to None
SUPABASE_REPLACE_DEFAULT_HEADERS (replace_default_headers): bool - defaults to False

"""

Supabase.configure(
    url = '...',
    key = "...",
    debug_enabled = True,
)

async def async_fetch_table(table: str = "profiles", select: str = "*"):
    # Async fetch
    # note that table is `atable` for async
    return await Supabase.atable(table).select(select).execute()

def fetch_table(table: str = "profiles", select: str = "*"):
    # Sync fetch
    return Supabase.table(table).select(select).execute()

async def async_fetch_users():
    # Async `ListUsers`
    # note that most async methods are prefixed with
    # `async_` 
    return await Supabase.auth.async_list_users()

def fetch_users():
    # Sync `ListUsers`
    # note that most async methods are prefixed with
    return Supabase.auth.list_users()

async def run_test():
    # Async fetch
    async_data = await async_fetch_table()
    logger.info(f"async_data: {async_data}")

    async_users = await async_fetch_users()
    logger.info(f"async_users: {async_users}")

    # Sync fetch
    sync_data = fetch_table()
    logger.info(f"sync_data: {sync_data}")

    sync_users = fetch_users()
    logger.info(f"sync_users: {sync_users}")


asyncio.run(run_test())

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

aiosupabase-0.0.3.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

aiosupabase-0.0.3-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file aiosupabase-0.0.3.tar.gz.

File metadata

  • Download URL: aiosupabase-0.0.3.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for aiosupabase-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8dd2364549e2de449b61de44818d9613ce0727eed586ebfbbc814c77f41ef895
MD5 514de585c992b8ced3120a93616bd93d
BLAKE2b-256 166df0c9d1e9696c3f935520838ac86f73d11144b30bc444945265e96fe384df

See more details on using hashes here.

File details

Details for the file aiosupabase-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: aiosupabase-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for aiosupabase-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 82fe65ad956f2fb16d1a975f86147d932b1ee0463c90270cedd060447e1c20db
MD5 ace808f1058f7a240f28d80c6c5c287c
BLAKE2b-256 5df059c449fad6a3dc1454093baff3c8d26404ff8d61f183d6649a2833bcc5d1

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