Streamlit GSheets Connection

raw JSON →
0.1.0 verified Fri May 01 auth: no python

A Streamlit Connection for Google Sheets, providing a simple interface to read and write data using the official Streamlit Connections API. Current version is 0.1.0, with moderate release cadence.

pip install st-gsheets-connection
error ModuleNotFoundError: No module named 'st_gsheets_connection'
cause Installed the package but the import name is different. The package uses hyphen, import uses underscore.
fix
Run pip install st-gsheets-connection and then import with from st_gsheets_connection import GSheetsConnection.
error TypeError: GSheetsConnection() got multiple values for argument 'type'
cause Trying to instantiate GSheetsConnection directly with `type` argument that is only meant for `st.connection`.
fix
Use st.connection("gsheets", type=GSheetsConnection) and let Streamlit handle instantiation.
error ValueError: The 'credentials' argument must be a dict, a path to a service account file, or None.
cause Passed an unsupported type for credentials in `st.connection`.
fix
Provide credentials via Streamlit secrets as [connections.gsheets] with service_account JSON or type = "service_account".
breaking Version 0.1.0 includes a breaking change: the connection now requires Streamlit's new `st.connection` API. Old pattern using `GSheetsConnection` directly without `st.connection` no longer works.
fix Use `conn = st.connection("gsheets", type=GSheetsConnection)` instead of `GSheetsConnection(...)` directly.
gotcha The package name on PyPI is `st-gsheets-connection`, but the import module is `st_gsheets_connection`. Hyphen vs underscore mismatch often causes import errors.
fix Install with `pip install st-gsheets-connection`, then import with `from st_gsheets_connection import GSheetsConnection`.
deprecated `gspread` version 6.0 is not compatible with the latest version of `gspread-dataframe`. Ensure you install compatible versions.
fix Pin gspread to <6.0 or use gspread-dataframe compatible with gspread 6.0.

Basic example: creates a connection and reads a worksheet into a Pandas DataFrame.

import streamlit as st
from st_gsheets_connection import GSheetsConnection

conn = st.connection("gsheets", type=GSheetsConnection)
df = conn.read(worksheet="Sheet1")
st.dataframe(df)