|
9 | 9 |
|
10 | 10 | from streamlit_gsheets import GSheetsConnection |
11 | 11 |
|
12 | | - conn = st.experimental_connection("gsheets", type=GSheetsConnection) |
| 12 | + conn = st.connection("gsheets", type=GSheetsConnection) |
13 | 13 | st.write(conn) |
14 | 14 | st.help(conn) |
15 | 15 |
|
|
36 | 36 | and enable it. |
37 | 37 | 3. [Using Service |
38 | 38 | Account](https://docs.gspread.org/en/v5.7.1/oauth2.html#for-bots-using-service-account) |
39 | | - * Enable API Access for a Project if you haven’t done it yet. |
| 39 | + * Enable API Access for a Project if you haven't done it yet. |
40 | 40 | * Go to “APIs & Services > Credentials” and choose “Create credentials > Service |
41 | 41 | account key”. |
42 | 42 | * Fill out the form |
|
58 | 58 | ... |
59 | 59 | }} |
60 | 60 | ``` |
61 | | -Remember the path to the downloaded credentials file. Also, in the next step you’ll need |
| 61 | +Remember the path to the downloaded credentials file. Also, in the next step you'll need |
62 | 62 | the value of client_email from this file. |
63 | 63 |
|
64 | 64 | * **:red[Very important!]** Go to your |
65 | 65 | spreadsheet and share it with a client_email from the step above. Just like you do with |
66 | | -any other Google account. If you don’t do this, you’ll get a |
| 66 | +any other Google account. If you don't do this, you'll get a |
67 | 67 | `gspread.exceptions.SpreadsheetNotFound` exception when trying to access this |
68 | 68 | spreadsheet from your application or a script. |
69 | 69 |
|
|
105 | 105 | from streamlit_gsheets import GSheetsConnection |
106 | 106 |
|
107 | 107 | # Create GSheets connection |
108 | | - conn = st.experimental_connection("gsheets", type=GSheetsConnection) |
| 108 | + conn = st.connection("gsheets", type=GSheetsConnection) |
109 | 109 |
|
110 | 110 | # Demo Births DataFrame |
111 | 111 | df = psql.load_births() |
|
118 | 118 | data=df, |
119 | 119 | ) |
120 | 120 | st.cache_data.clear() |
121 | | - st.experimental_rerun() |
| 121 | + st.rerun() |
122 | 122 |
|
123 | 123 | # Display our Spreadsheet as st.dataframe |
124 | 124 | st.dataframe(df.head(10)) |
|
127 | 127 | st.write("#### 4. Read Google WorkSheet as DataFrame") |
128 | 128 | st.info( |
129 | 129 | "If the sheet has been deleted, press 'Create new worksheet' button above.", |
130 | | - icon="ℹ️", |
| 130 | + icon="ℹ️", # noqa: RUF001 |
131 | 131 | ) |
132 | 132 |
|
133 | 133 | with st.echo(): |
|
136 | 136 | from streamlit_gsheets import GSheetsConnection |
137 | 137 |
|
138 | 138 | # Create GSheets connection |
139 | | - conn = st.experimental_connection("gsheets", type=GSheetsConnection) |
| 139 | + conn = st.connection("gsheets", type=GSheetsConnection) |
140 | 140 |
|
141 | 141 | # Read Google WorkSheet as DataFrame |
142 | 142 | df = conn.read( |
|
157 | 157 | from streamlit_gsheets import GSheetsConnection |
158 | 158 |
|
159 | 159 | # Create GSheets connection |
160 | | - conn = st.experimental_connection("gsheets", type=GSheetsConnection) |
| 160 | + conn = st.connection("gsheets", type=GSheetsConnection) |
161 | 161 |
|
162 | 162 | # Demo Meat DataFrame |
163 | 163 | df = psql.load_meat() |
|
170 | 170 | data=df, |
171 | 171 | ) |
172 | 172 | st.cache_data.clear() |
173 | | - st.experimental_rerun() |
| 173 | + st.rerun() |
174 | 174 |
|
175 | 175 | # Display our Spreadsheet as st.dataframe |
176 | 176 | st.dataframe(df.head(10)) |
177 | 177 |
|
178 | 178 | st.write("#### 6. Query Google WorkSheet with SQL and get results as DataFrame") |
179 | 179 | st.info( |
180 | 180 | "Mutation SQL queries are in-memory only and do not results in the Worksheet update.", |
181 | | - icon="ℹ️", |
| 181 | + icon="ℹ️", # noqa: RUF001 |
182 | 182 | ) |
183 | 183 |
|
184 | 184 |
|
|
188 | 188 | from streamlit_gsheets import GSheetsConnection |
189 | 189 |
|
190 | 190 | # Create GSheets connection |
191 | | - conn = st.experimental_connection("gsheets", type=GSheetsConnection) |
| 191 | + conn = st.connection("gsheets", type=GSheetsConnection) |
192 | 192 |
|
193 | 193 | # make sure worksheet name is in double quota "", in our case it's "Example 1" |
194 | 194 | # DuckDB SQL dialect is supported |
|
206 | 206 | from streamlit_gsheets import GSheetsConnection |
207 | 207 |
|
208 | 208 | # Create GSheets connection |
209 | | - conn = st.experimental_connection("gsheets", type=GSheetsConnection) |
| 209 | + conn = st.connection("gsheets", type=GSheetsConnection) |
210 | 210 |
|
211 | 211 | # click button to update worksheet |
212 | 212 | # This is behind a button to avoid exceeding Google API Quota |
213 | 213 | if st.button("Clear worksheet"): |
214 | 214 | conn.clear(worksheet="Example 1") |
215 | 215 | st.info("Worksheet Example 1 Cleared!") |
216 | 216 | st.cache_data.clear() |
217 | | - st.experimental_rerun() |
| 217 | + st.rerun() |
218 | 218 |
|
219 | 219 | # click button to delete worksheet using the underlying gspread API |
220 | 220 | # This is behind a button to avoid exceeding Google API Quota |
|
223 | 223 | worksheet = spreadsheet.worksheet("Example 1") |
224 | 224 | spreadsheet.del_worksheet(worksheet) |
225 | 225 | st.cache_data.clear() |
226 | | - st.experimental_rerun() |
| 226 | + st.rerun() |
0 commit comments