Skip to content

Commit

Permalink
Merge pull request #5 from streamlit/fix-instructions
Browse files Browse the repository at this point in the history
Fix instructions
  • Loading branch information
sfc-gh-jcarroll authored Jul 21, 2023
2 parents 2ad623d + 333efa2 commit 01a419c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,36 @@
Connect to public or private Google Sheets from your Streamlit app. Powered by `st.experimental_connection()` and [gspread](https://github.com/burnash/gspread).

GSheets Connection works in two modes:

* in Read Only mode, using publicly shared Spreadsheet URLs (Read Only mode)
* CRUD operations support mode, with Authentication using Service Account. In order to use Service Account mode you need to enable Google Drive and Google Sheets API in [Google Developers Console](https://console.developers.google.com/).
Follow **Initial setup for CRUD mode** section in order to authenticate your Streamlit app first.

## Initial setup for CRUD mode
## Install

```sh
pip install streamlit git+https://github.com/streamlit/gsheets-connection
```

## Minimal example: publicly shared spreadsheet (read-only)

```python
# example/st_app.py

import streamlit as st
from streamlit_gsheets import GSheetsConnection

url = "https://docs.google.com/spreadsheets/d/1JDy9md2VZPz4JbYtRPJLs81_3jUK47nx6GYQjgU8qNY/edit?usp=sharing"

conn = st.experimental_connection("gsheets", type=GSheetsConnection)

data = conn.read(spreadsheet=url, usecols=[0, 1])
st.dataframe(data)
```

## Service account / CRUD example

### Initial setup for private spreadsheet and/or CRUD mode

1. Setup `.streamlit/secrets.toml` inside your Streamlit app root directory,
check out [Secret management documentation](https://docs.streamlit.io/streamlit-community-cloud/get-started/deploy-an-app/connect-to-data-sources/secrets-management) for references.
Expand Down Expand Up @@ -58,22 +83,7 @@ auth_provider_x509_cert_url = ""
client_x509_cert_url = ""
```

## Publicly Shared Spreadsheet Example
```python
# example/st_app.py

import streamlit as st
from streamlit_gsheets import GSheetsConnection

url = "https://docs.google.com/spreadsheets/d/1JDy9md2VZPz4JbYtRPJLs81_3jUK47nx6GYQjgU8qNY/edit?usp=sharing"

conn = st.experimental_connection("gsheets", type=GSheetsConnection)

data = conn.read(spreadsheet=url, usecols=[0, 1])
st.dataframe(data)
```

## Service Account Example
### Code

```python
# example/st_app_gsheets_using_service_account.py
Expand Down Expand Up @@ -111,11 +121,10 @@ client_x509_cert_url = ""
# requirements.txt
streamlit==1.22
git+https://github.com/sfc-gh-jcarroll/st-connection-prpr.git#subdirectory=gsheets_connection
git+https://github.com/streamlit/gsheets-connection
pandasql # this is for example/st_app.py only
```


## Full example
Check gsheets_connection/example directory for full example of the usage.

Expand Down
5 changes: 2 additions & 3 deletions examples/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
../../streamlit-1.21.0-py2.py3-none-any.whl
# streamlit==1.22
# git+https://github.com/sfc-gh-jcarroll/st-connection-prpr.git#subdirectory=gsheets_connection
streamlit==1.22
git+https://github.com/streamlit/gsheets-connection
pandasql # this is for examples/ only
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
NAME = "streamlit_gsheets"

INSTALL_REQUIRES = [
"streamlit>=1.21.0",
"streamlit>=1.22.0",
"gspread>=5.8.0",
"gspread-pandas>=3.2.2",
"gspread-dataframe>=3.3.0",
Expand All @@ -20,9 +20,9 @@
name=NAME,
version=VERSION,
description="Streamlit Connection for Google Sheets.",
url="https://github.com/sfc-gh-jcarroll/st-connection-prpr",
url="https://github.com/streamlit/gsheets-connection",
project_urls={
"Source Code": "https://github.com/sfc-gh-jcarroll/st-connection-prpr",
"Source Code": "https://github.com/streamlit/gsheets-connection",
},
author="Tomasz Szerszeń",
author_email="[email protected]",
Expand Down

0 comments on commit 01a419c

Please sign in to comment.