A Streamlit connection component for Supabase.
Project description
:lock: st-supabase-connection
A streamlit component that creates a user login form connected to a Supabase DB. It lets users create a new username and password, login to an existing account, or login as an anonymous guest.
The login form collapses after login to free screen-space.
:computer: Demo app
:construction: Installation
- Install
st-supabase-connection
pip install st-supabase-connection
- Create a Supabase project as mentioned here
- Create a table to store the usernames and passwords. The table name and column names can be as per your choice.
CREATE TABLE users (
username text not null default ''::text,
password text not null,
constraint users_pkey primary key (username),
constraint users_username_key unique (username),
constraint users_password_check check (
(
length(
trim(
both
from
password
)
) > 1
)
),
constraint users_username_check check (
(
length(
trim(
both
from
username
)
) > 1
)
)
) tablespace pg_default;
- Follow the rest of the steps from here to connect your Streamlit app to Supabase
:pen: Usage
login_form() sets session_state["authenticated"] to True if the login is successful, session_state["username"] to the username or new or existing user, and to None for guest login.
Returns the initialized supabase.Client instance to let you interact with the databse downstream in the script.
import streamlit as st
from streamlit_login import login_form
client = login_form()
if st.session_state["authenticated"]:
if st.session_state["username"]:
st.success(f"Welcome {st.session_state['username']}")
else:
st.success("Welcome guest")
else:
st.error("Not authenticated")
🤗 Want to support my work?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file st-supabase-connection-0.0.0.tar.gz.
File metadata
- Download URL: st-supabase-connection-0.0.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aacb15541d7711ee6607990fb1f20172fdf9f00e9594c4ef868d9fb59644e52
|
|
| MD5 |
d8b8ec75457cda0f8ac7be5d7304b72c
|
|
| BLAKE2b-256 |
82584d1df1902fc4dc50719d1011fa98fba3337199861248fa979adf960672d6
|
File details
Details for the file st_supabase_connection-0.0.0-py3-none-any.whl.
File metadata
- Download URL: st_supabase_connection-0.0.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d56549e5407fda7b8718e5c190e13cfb5a37a5c2ece803062761c235308b9a6c
|
|
| MD5 |
6cc1d07947e7e1eb7cb78b19b2442a7b
|
|
| BLAKE2b-256 |
5280ea35630eef01eb7760a0cb8430e510c3d6e07d0284b7491a185d16affd78
|