streamlit-nightly 1.36.1.dev20240706__py2.py3-none-any.whl → 1.36.1.dev20240708__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/code_util.py +1 -1
- streamlit/commands/execution_control.py +2 -2
- streamlit/commands/logo.py +5 -1
- streamlit/commands/navigation.py +5 -5
- streamlit/connections/base_connection.py +1 -1
- streamlit/connections/snowpark_connection.py +1 -1
- streamlit/connections/sql_connection.py +5 -1
- streamlit/delta_generator.py +14 -14
- streamlit/elements/arrow.py +19 -11
- streamlit/elements/bokeh_chart.py +2 -6
- streamlit/elements/code.py +1 -1
- streamlit/elements/deck_gl_json_chart.py +32 -29
- streamlit/elements/doc_string.py +1 -1
- streamlit/elements/empty.py +1 -1
- streamlit/elements/exception.py +1 -1
- streamlit/elements/form.py +7 -8
- streamlit/elements/graphviz_chart.py +13 -13
- streamlit/elements/heading.py +6 -6
- streamlit/elements/html.py +3 -1
- streamlit/elements/image.py +1 -1
- streamlit/elements/json.py +12 -10
- streamlit/elements/layouts.py +21 -21
- streamlit/elements/lib/built_in_chart_utils.py +7 -5
- streamlit/elements/markdown.py +3 -3
- streamlit/elements/media.py +2 -2
- streamlit/elements/metric.py +4 -4
- streamlit/elements/spinner.py +1 -1
- streamlit/elements/text.py +1 -1
- streamlit/elements/vega_charts.py +56 -33
- streamlit/elements/widgets/button.py +5 -5
- streamlit/elements/widgets/file_uploader.py +3 -1
- streamlit/elements/widgets/multiselect.py +2 -1
- streamlit/elements/widgets/number_input.py +6 -2
- streamlit/elements/widgets/radio.py +6 -1
- streamlit/elements/widgets/select_slider.py +21 -3
- streamlit/elements/widgets/selectbox.py +6 -5
- streamlit/elements/widgets/slider.py +5 -6
- streamlit/elements/widgets/text_widgets.py +1 -1
- streamlit/elements/write.py +17 -13
- streamlit/runtime/caching/cache_data_api.py +3 -3
- streamlit/runtime/caching/cache_resource_api.py +3 -3
- streamlit/runtime/caching/legacy_cache_api.py +1 -1
- streamlit/runtime/connection_factory.py +10 -4
- streamlit/static/asset-manifest.json +5 -5
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{2736.4336e2b9.chunk.js → 2736.7d516fcc.chunk.js} +1 -1
- streamlit/static/static/js/3301.0cd98943.chunk.js +1 -0
- streamlit/static/static/js/7175.4cdaec13.chunk.js +1 -0
- streamlit/static/static/js/{main.28e3c6e9.js → main.8729b772.js} +2 -2
- streamlit/testing/v1/util.py +2 -2
- streamlit/type_util.py +1 -1
- {streamlit_nightly-1.36.1.dev20240706.dist-info → streamlit_nightly-1.36.1.dev20240708.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.36.1.dev20240706.dist-info → streamlit_nightly-1.36.1.dev20240708.dist-info}/RECORD +58 -58
- streamlit/static/static/js/3301.1d1b10bb.chunk.js +0 -1
- streamlit/static/static/js/7175.8f4014ec.chunk.js +0 -1
- /streamlit/static/static/js/{main.28e3c6e9.js.LICENSE.txt → main.8729b772.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.36.1.dev20240706.data → streamlit_nightly-1.36.1.dev20240708.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.36.1.dev20240706.dist-info → streamlit_nightly-1.36.1.dev20240708.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.36.1.dev20240706.dist-info → streamlit_nightly-1.36.1.dev20240708.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.36.1.dev20240706.dist-info → streamlit_nightly-1.36.1.dev20240708.dist-info}/top_level.txt +0 -0
@@ -185,7 +185,9 @@ class VegaLiteState(TypedDict, total=False):
|
|
185
185
|
... },
|
186
186
|
... }
|
187
187
|
>>>
|
188
|
-
>>> event = st.vega_lite_chart(
|
188
|
+
>>> event = st.vega_lite_chart(
|
189
|
+
... st.session_state.data, spec, key="vega_chart", on_select="rerun"
|
190
|
+
... )
|
189
191
|
>>>
|
190
192
|
>>> event
|
191
193
|
|
@@ -682,11 +684,11 @@ class VegaChartsMixin:
|
|
682
684
|
>>> import numpy as np
|
683
685
|
>>>
|
684
686
|
>>> chart_data = pd.DataFrame(
|
685
|
-
...
|
686
|
-
...
|
687
|
-
...
|
688
|
-
...
|
689
|
-
...
|
687
|
+
... {
|
688
|
+
... "col1": np.random.randn(20),
|
689
|
+
... "col2": np.random.randn(20),
|
690
|
+
... "col3": np.random.choice(["A", "B", "C"], 20),
|
691
|
+
... }
|
690
692
|
... )
|
691
693
|
>>>
|
692
694
|
>>> st.line_chart(chart_data, x="col1", y="col2", color="col3")
|
@@ -703,10 +705,15 @@ class VegaChartsMixin:
|
|
703
705
|
>>> import pandas as pd
|
704
706
|
>>> import numpy as np
|
705
707
|
>>>
|
706
|
-
>>> chart_data = pd.DataFrame(
|
708
|
+
>>> chart_data = pd.DataFrame(
|
709
|
+
... np.random.randn(20, 3), columns=["col1", "col2", "col3"]
|
710
|
+
... )
|
707
711
|
>>>
|
708
712
|
>>> st.line_chart(
|
709
|
-
...
|
713
|
+
... chart_data,
|
714
|
+
... x="col1",
|
715
|
+
... y=["col2", "col3"],
|
716
|
+
... color=["#FF0000", "#0000FF"], # Optional
|
710
717
|
... )
|
711
718
|
|
712
719
|
.. output::
|
@@ -875,11 +882,11 @@ class VegaChartsMixin:
|
|
875
882
|
>>> import numpy as np
|
876
883
|
>>>
|
877
884
|
>>> chart_data = pd.DataFrame(
|
878
|
-
...
|
879
|
-
...
|
880
|
-
...
|
881
|
-
...
|
882
|
-
...
|
885
|
+
... {
|
886
|
+
... "col1": np.random.randn(20),
|
887
|
+
... "col2": np.random.randn(20),
|
888
|
+
... "col3": np.random.choice(["A", "B", "C"], 20),
|
889
|
+
... }
|
883
890
|
... )
|
884
891
|
>>>
|
885
892
|
>>> st.area_chart(chart_data, x="col1", y="col2", color="col3")
|
@@ -896,10 +903,15 @@ class VegaChartsMixin:
|
|
896
903
|
>>> import pandas as pd
|
897
904
|
>>> import numpy as np
|
898
905
|
>>>
|
899
|
-
>>> chart_data = pd.DataFrame(
|
906
|
+
>>> chart_data = pd.DataFrame(
|
907
|
+
... np.random.randn(20, 3), columns=["col1", "col2", "col3"]
|
908
|
+
... )
|
900
909
|
>>>
|
901
910
|
>>> st.area_chart(
|
902
|
-
...
|
911
|
+
... chart_data,
|
912
|
+
... x="col1",
|
913
|
+
... y=["col2", "col3"],
|
914
|
+
... color=["#FF0000", "#0000FF"], # Optional
|
903
915
|
... )
|
904
916
|
|
905
917
|
.. output::
|
@@ -1084,11 +1096,11 @@ class VegaChartsMixin:
|
|
1084
1096
|
>>> import numpy as np
|
1085
1097
|
>>>
|
1086
1098
|
>>> chart_data = pd.DataFrame(
|
1087
|
-
...
|
1088
|
-
...
|
1089
|
-
...
|
1090
|
-
...
|
1091
|
-
...
|
1099
|
+
... {
|
1100
|
+
... "col1": list(range(20)) * 3,
|
1101
|
+
... "col2": np.random.randn(60),
|
1102
|
+
... "col3": ["A"] * 20 + ["B"] * 20 + ["C"] * 20,
|
1103
|
+
... }
|
1092
1104
|
... )
|
1093
1105
|
>>>
|
1094
1106
|
>>> st.bar_chart(chart_data, x="col1", y="col2", color="col3")
|
@@ -1106,11 +1118,18 @@ class VegaChartsMixin:
|
|
1106
1118
|
>>> import numpy as np
|
1107
1119
|
>>>
|
1108
1120
|
>>> chart_data = pd.DataFrame(
|
1109
|
-
...
|
1121
|
+
... {
|
1122
|
+
... "col1": list(range(20)),
|
1123
|
+
... "col2": np.random.randn(20),
|
1124
|
+
... "col3": np.random.randn(20),
|
1125
|
+
... }
|
1110
1126
|
... )
|
1111
1127
|
>>>
|
1112
1128
|
>>> st.bar_chart(
|
1113
|
-
...
|
1129
|
+
... chart_data,
|
1130
|
+
... x="col1",
|
1131
|
+
... y=["col2", "col3"],
|
1132
|
+
... color=["#FF0000", "#0000FF"], # Optional
|
1114
1133
|
... )
|
1115
1134
|
|
1116
1135
|
.. output::
|
@@ -1320,15 +1339,17 @@ class VegaChartsMixin:
|
|
1320
1339
|
>>> import pandas as pd
|
1321
1340
|
>>> import numpy as np
|
1322
1341
|
>>>
|
1323
|
-
>>> chart_data = pd.DataFrame(
|
1324
|
-
|
1342
|
+
>>> chart_data = pd.DataFrame(
|
1343
|
+
... np.random.randn(20, 3), columns=["col1", "col2", "col3"]
|
1344
|
+
... )
|
1345
|
+
>>> chart_data["col4"] = np.random.choice(["A", "B", "C"], 20)
|
1325
1346
|
>>>
|
1326
1347
|
>>> st.scatter_chart(
|
1327
1348
|
... chart_data,
|
1328
|
-
... x=
|
1329
|
-
... y=
|
1330
|
-
... color=
|
1331
|
-
... size=
|
1349
|
+
... x="col1",
|
1350
|
+
... y="col2",
|
1351
|
+
... color="col4",
|
1352
|
+
... size="col3",
|
1332
1353
|
... )
|
1333
1354
|
|
1334
1355
|
.. output::
|
@@ -1343,14 +1364,16 @@ class VegaChartsMixin:
|
|
1343
1364
|
>>> import pandas as pd
|
1344
1365
|
>>> import numpy as np
|
1345
1366
|
>>>
|
1346
|
-
>>> chart_data = pd.DataFrame(
|
1367
|
+
>>> chart_data = pd.DataFrame(
|
1368
|
+
... np.random.randn(20, 4), columns=["col1", "col2", "col3", "col4"]
|
1369
|
+
... )
|
1347
1370
|
>>>
|
1348
1371
|
>>> st.scatter_chart(
|
1349
1372
|
... chart_data,
|
1350
|
-
... x=
|
1351
|
-
... y=[
|
1352
|
-
... size=
|
1353
|
-
... color=[
|
1373
|
+
... x="col1",
|
1374
|
+
... y=["col2", "col3"],
|
1375
|
+
... size="col4",
|
1376
|
+
... color=["#FF0000", "#0000FF"], # Optional
|
1354
1377
|
... )
|
1355
1378
|
|
1356
1379
|
.. output::
|
@@ -331,11 +331,11 @@ class ButtonMixin:
|
|
331
331
|
>>>
|
332
332
|
>>> with open("flower.png", "rb") as file:
|
333
333
|
... btn = st.download_button(
|
334
|
-
...
|
335
|
-
...
|
336
|
-
...
|
337
|
-
...
|
338
|
-
...
|
334
|
+
... label="Download image",
|
335
|
+
... data=file,
|
336
|
+
... file_name="flower.png",
|
337
|
+
... mime="image/png",
|
338
|
+
... )
|
339
339
|
|
340
340
|
.. output::
|
341
341
|
https://doc-download-buton.streamlit.app/
|
@@ -359,7 +359,9 @@ class FileUploaderMixin:
|
|
359
359
|
|
360
360
|
>>> import streamlit as st
|
361
361
|
>>>
|
362
|
-
>>> uploaded_files = st.file_uploader(
|
362
|
+
>>> uploaded_files = st.file_uploader(
|
363
|
+
... "Choose a CSV file", accept_multiple_files=True
|
364
|
+
... )
|
363
365
|
>>> for uploaded_file in uploaded_files:
|
364
366
|
... bytes_data = uploaded_file.read()
|
365
367
|
... st.write("filename:", uploaded_file.name)
|
@@ -241,7 +241,8 @@ class MultiSelectMixin:
|
|
241
241
|
>>> options = st.multiselect(
|
242
242
|
... "What are your favorite colors",
|
243
243
|
... ["Green", "Yellow", "Red", "Blue"],
|
244
|
-
... ["Yellow", "Red"]
|
244
|
+
... ["Yellow", "Red"],
|
245
|
+
... )
|
245
246
|
>>>
|
246
247
|
>>> st.write("You selected:", options)
|
247
248
|
|
@@ -191,7 +191,9 @@ class NumberInputMixin:
|
|
191
191
|
format : str or None
|
192
192
|
A printf-style format string controlling how the interface should
|
193
193
|
display numbers. Output must be purely numeric. This does not impact
|
194
|
-
the return value.
|
194
|
+
the return value. Formatting is handled by [sprintf.js](https://github.com/alexei/sprintf.js).
|
195
|
+
This can be used to adjust decimal precision in the displayed result. For example,
|
196
|
+
``'%0.1f'`` to only show 1 digit after the decimal.
|
195
197
|
key : str or int
|
196
198
|
An optional string or integer to use as the unique key for the widget.
|
197
199
|
If this is omitted, a key will be generated for the widget
|
@@ -238,7 +240,9 @@ class NumberInputMixin:
|
|
238
240
|
|
239
241
|
>>> import streamlit as st
|
240
242
|
>>>
|
241
|
-
>>> number = st.number_input(
|
243
|
+
>>> number = st.number_input(
|
244
|
+
... "Insert a number", value=None, placeholder="Type a number..."
|
245
|
+
... )
|
242
246
|
>>> st.write("The current number is ", number)
|
243
247
|
|
244
248
|
.. output::
|
@@ -188,7 +188,12 @@ class RadioMixin:
|
|
188
188
|
>>> genre = st.radio(
|
189
189
|
... "What's your favorite movie genre",
|
190
190
|
... [":rainbow[Comedy]", "***Drama***", "Documentary :movie_camera:"],
|
191
|
-
... captions
|
191
|
+
... captions=[
|
192
|
+
... "Laugh out loud.",
|
193
|
+
... "Get the popcorn.",
|
194
|
+
... "Never stop learning.",
|
195
|
+
... ],
|
196
|
+
... )
|
192
197
|
>>>
|
193
198
|
>>> if genre == ":rainbow[Comedy]":
|
194
199
|
... st.write("You selected comedy.")
|
@@ -209,7 +209,16 @@ class SelectSliderMixin:
|
|
209
209
|
>>>
|
210
210
|
>>> color = st.select_slider(
|
211
211
|
... "Select a color of the rainbow",
|
212
|
-
... options=[
|
212
|
+
... options=[
|
213
|
+
... "red",
|
214
|
+
... "orange",
|
215
|
+
... "yellow",
|
216
|
+
... "green",
|
217
|
+
... "blue",
|
218
|
+
... "indigo",
|
219
|
+
... "violet",
|
220
|
+
... ],
|
221
|
+
... )
|
213
222
|
>>> st.write("My favorite color is", color)
|
214
223
|
|
215
224
|
And here's an example of a range select slider:
|
@@ -218,8 +227,17 @@ class SelectSliderMixin:
|
|
218
227
|
>>>
|
219
228
|
>>> start_color, end_color = st.select_slider(
|
220
229
|
... "Select a range of color wavelength",
|
221
|
-
... options=[
|
222
|
-
...
|
230
|
+
... options=[
|
231
|
+
... "red",
|
232
|
+
... "orange",
|
233
|
+
... "yellow",
|
234
|
+
... "green",
|
235
|
+
... "blue",
|
236
|
+
... "indigo",
|
237
|
+
... "violet",
|
238
|
+
... ],
|
239
|
+
... value=("red", "blue"),
|
240
|
+
... )
|
223
241
|
>>> st.write("You selected wavelengths between", start_color, "and", end_color)
|
224
242
|
|
225
243
|
.. output::
|
@@ -172,7 +172,8 @@ class SelectboxMixin:
|
|
172
172
|
>>>
|
173
173
|
>>> option = st.selectbox(
|
174
174
|
... "How would you like to be contacted?",
|
175
|
-
... ("Email", "Home phone", "Mobile phone")
|
175
|
+
... ("Email", "Home phone", "Mobile phone"),
|
176
|
+
... )
|
176
177
|
>>>
|
177
178
|
>>> st.write("You selected:", option)
|
178
179
|
|
@@ -185,10 +186,10 @@ class SelectboxMixin:
|
|
185
186
|
>>> import streamlit as st
|
186
187
|
>>>
|
187
188
|
>>> option = st.selectbox(
|
188
|
-
...
|
189
|
-
...
|
190
|
-
...
|
191
|
-
...
|
189
|
+
... "How would you like to be contacted?",
|
190
|
+
... ("Email", "Home phone", "Mobile phone"),
|
191
|
+
... index=None,
|
192
|
+
... placeholder="Select contact method...",
|
192
193
|
... )
|
193
194
|
>>>
|
194
195
|
>>> st.write("You selected:", option)
|
@@ -303,9 +303,7 @@ class SliderMixin:
|
|
303
303
|
|
304
304
|
>>> import streamlit as st
|
305
305
|
>>>
|
306
|
-
>>> values = st.slider(
|
307
|
-
... "Select a range of values",
|
308
|
-
... 0.0, 100.0, (25.0, 75.0))
|
306
|
+
>>> values = st.slider("Select a range of values", 0.0, 100.0, (25.0, 75.0))
|
309
307
|
>>> st.write("Values:", values)
|
310
308
|
|
311
309
|
This is a range time slider:
|
@@ -314,8 +312,8 @@ class SliderMixin:
|
|
314
312
|
>>> from datetime import time
|
315
313
|
>>>
|
316
314
|
>>> appointment = st.slider(
|
317
|
-
... "Schedule your appointment:",
|
318
|
-
...
|
315
|
+
... "Schedule your appointment:", value=(time(11, 30), time(12, 45))
|
316
|
+
... )
|
319
317
|
>>> st.write("You're scheduled for:", appointment)
|
320
318
|
|
321
319
|
Finally, a datetime slider:
|
@@ -326,7 +324,8 @@ class SliderMixin:
|
|
326
324
|
>>> start_time = st.slider(
|
327
325
|
... "When do you start?",
|
328
326
|
... value=datetime(2020, 1, 1, 9, 30),
|
329
|
-
... format="MM/DD/YY - hh:mm"
|
327
|
+
... format="MM/DD/YY - hh:mm",
|
328
|
+
... )
|
330
329
|
>>> st.write("Start time:", start_time)
|
331
330
|
|
332
331
|
.. output::
|
@@ -488,7 +488,7 @@ class TextWidgetsMixin:
|
|
488
488
|
... "was the epoch of incredulity, it was the season of Light, it was the "
|
489
489
|
... "season of Darkness, it was the spring of hope, it was the winter of "
|
490
490
|
... "despair, (...)",
|
491
|
-
...
|
491
|
+
... )
|
492
492
|
>>>
|
493
493
|
>>> st.write(f"You wrote {len(txt)} characters.")
|
494
494
|
|
streamlit/elements/write.py
CHANGED
@@ -302,7 +302,7 @@ class WriteMixin:
|
|
302
302
|
|
303
303
|
>>> import streamlit as st
|
304
304
|
>>>
|
305
|
-
>>> st.write(
|
305
|
+
>>> st.write("Hello, *World!* :sunglasses:")
|
306
306
|
|
307
307
|
.. output::
|
308
308
|
https://doc-write1.streamlit.app/
|
@@ -315,10 +315,14 @@ class WriteMixin:
|
|
315
315
|
>>> import pandas as pd
|
316
316
|
>>>
|
317
317
|
>>> st.write(1234)
|
318
|
-
>>> st.write(
|
319
|
-
...
|
320
|
-
...
|
321
|
-
...
|
318
|
+
>>> st.write(
|
319
|
+
... pd.DataFrame(
|
320
|
+
... {
|
321
|
+
... "first column": [1, 2, 3, 4],
|
322
|
+
... "second column": [10, 20, 30, 40],
|
323
|
+
... }
|
324
|
+
... )
|
325
|
+
... )
|
322
326
|
|
323
327
|
.. output::
|
324
328
|
https://doc-write2.streamlit.app/
|
@@ -328,8 +332,8 @@ class WriteMixin:
|
|
328
332
|
|
329
333
|
>>> import streamlit as st
|
330
334
|
>>>
|
331
|
-
>>> st.write(
|
332
|
-
>>> st.write(
|
335
|
+
>>> st.write("1 + 1 = ", 2)
|
336
|
+
>>> st.write("Below is a DataFrame:", data_frame, "Above is a dataframe.")
|
333
337
|
|
334
338
|
.. output::
|
335
339
|
https://doc-write3.streamlit.app/
|
@@ -342,12 +346,12 @@ class WriteMixin:
|
|
342
346
|
>>> import numpy as np
|
343
347
|
>>> import altair as alt
|
344
348
|
>>>
|
345
|
-
>>> df = pd.DataFrame(
|
346
|
-
|
347
|
-
...
|
348
|
-
...
|
349
|
-
|
350
|
-
...
|
349
|
+
>>> df = pd.DataFrame(np.random.randn(200, 3), columns=["a", "b", "c"])
|
350
|
+
>>> c = (
|
351
|
+
... alt.Chart(df)
|
352
|
+
... .mark_circle()
|
353
|
+
... .encode(x="a", y="b", size="c", color="c", tooltip=["a", "b", "c"])
|
354
|
+
... )
|
351
355
|
>>>
|
352
356
|
>>> st.write(c)
|
353
357
|
|
@@ -467,7 +467,7 @@ class CacheDataAPI:
|
|
467
467
|
... def fetch_and_clean_data(url):
|
468
468
|
... # Fetch data from URL here, and then clean it up.
|
469
469
|
... return data
|
470
|
-
|
470
|
+
>>>
|
471
471
|
>>> d1 = fetch_and_clean_data(DATA_URL_1)
|
472
472
|
>>> # Actually executes the function, since this is the first time it was
|
473
473
|
>>> # encountered.
|
@@ -498,7 +498,7 @@ class CacheDataAPI:
|
|
498
498
|
... def fetch_and_clean_data(_db_connection, num_rows):
|
499
499
|
... # Fetch data from _db_connection here, and then clean it up.
|
500
500
|
... return data
|
501
|
-
|
501
|
+
>>>
|
502
502
|
>>> connection = make_database_connection()
|
503
503
|
>>> d1 = fetch_and_clean_data(connection, num_rows=10)
|
504
504
|
>>> # Actually executes the function, since this is the first time it was
|
@@ -518,7 +518,7 @@ class CacheDataAPI:
|
|
518
518
|
... def fetch_and_clean_data(_db_connection, num_rows):
|
519
519
|
... # Fetch data from _db_connection here, and then clean it up.
|
520
520
|
... return data
|
521
|
-
|
521
|
+
>>>
|
522
522
|
>>> fetch_and_clean_data.clear(_db_connection, 50)
|
523
523
|
>>> # Clear the cached entry for the arguments provided.
|
524
524
|
>>>
|
@@ -339,7 +339,7 @@ class CacheResourceAPI:
|
|
339
339
|
... def get_database_session(url):
|
340
340
|
... # Create a database session object that points to the URL.
|
341
341
|
... return session
|
342
|
-
|
342
|
+
>>>
|
343
343
|
>>> s1 = get_database_session(SESSION_URL_1)
|
344
344
|
>>> # Actually executes the function, since this is the first time it was
|
345
345
|
>>> # encountered.
|
@@ -361,7 +361,7 @@ class CacheResourceAPI:
|
|
361
361
|
... def get_database_session(_sessionmaker, url):
|
362
362
|
... # Create a database connection object that points to the URL.
|
363
363
|
... return connection
|
364
|
-
|
364
|
+
>>>
|
365
365
|
>>> s1 = get_database_session(create_sessionmaker(), DATA_URL_1)
|
366
366
|
>>> # Actually executes the function, since this is the first time it was
|
367
367
|
>>> # encountered.
|
@@ -379,7 +379,7 @@ class CacheResourceAPI:
|
|
379
379
|
... def get_database_session(_sessionmaker, url):
|
380
380
|
... # Create a database connection object that points to the URL.
|
381
381
|
... return connection
|
382
|
-
|
382
|
+
>>>
|
383
383
|
>>> fetch_and_clean_data.clear(_sessionmaker, "https://streamlit.io/")
|
384
384
|
>>> # Clear the cached entry for the arguments provided.
|
385
385
|
>>>
|
@@ -90,7 +90,7 @@ def cache(
|
|
90
90
|
... def fetch_and_clean_data(url):
|
91
91
|
... # Fetch data from URL here, and then clean it up.
|
92
92
|
... return data
|
93
|
-
|
93
|
+
>>>
|
94
94
|
>>> d1 = fetch_and_clean_data(DATA_URL_1)
|
95
95
|
>>> # Actually executes the function, since this is the first time it was
|
96
96
|
>>> # encountered.
|
@@ -252,21 +252,27 @@ def connection_factory(
|
|
252
252
|
file.
|
253
253
|
|
254
254
|
>>> import streamlit as st
|
255
|
-
>>> conn = st.connection("sql")
|
255
|
+
>>> conn = st.connection("sql") # [connections.sql] section in secrets.toml.
|
256
256
|
|
257
257
|
Creating a SQLConnection with a custom name requires you to explicitly specify the
|
258
258
|
type. If type is not passed as a kwarg, it must be set in the appropriate section of
|
259
259
|
``secrets.toml``.
|
260
260
|
|
261
261
|
>>> import streamlit as st
|
262
|
-
>>> conn1 = st.connection(
|
263
|
-
|
262
|
+
>>> conn1 = st.connection(
|
263
|
+
... "my_sql_connection", type="sql"
|
264
|
+
... ) # Config section defined in [connections.my_sql_connection].
|
265
|
+
>>> conn2 = st.connection(
|
266
|
+
... "my_other_sql_connection"
|
267
|
+
... ) # type must be set in [connections.my_other_sql_connection].
|
264
268
|
|
265
269
|
Passing the full module path to the connection class that you want to use can be
|
266
270
|
useful, especially when working with a custom connection:
|
267
271
|
|
268
272
|
>>> import streamlit as st
|
269
|
-
>>> conn = st.connection(
|
273
|
+
>>> conn = st.connection(
|
274
|
+
... "my_sql_connection", type="streamlit.connections.SQLConnection"
|
275
|
+
... )
|
270
276
|
|
271
277
|
Finally, you can pass the connection class to use directly to this function. Doing
|
272
278
|
so allows static type checking tools such as ``mypy`` to infer the exact return
|
@@ -1,11 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
3
|
"main.css": "./static/css/main.29bca1b5.css",
|
4
|
-
"main.js": "./static/js/main.
|
4
|
+
"main.js": "./static/js/main.8729b772.js",
|
5
5
|
"static/js/9336.3e046ad7.chunk.js": "./static/js/9336.3e046ad7.chunk.js",
|
6
6
|
"static/js/9330.2b4c99e0.chunk.js": "./static/js/9330.2b4c99e0.chunk.js",
|
7
|
-
"static/js/2736.
|
8
|
-
"static/js/3301.
|
7
|
+
"static/js/2736.7d516fcc.chunk.js": "./static/js/2736.7d516fcc.chunk.js",
|
8
|
+
"static/js/3301.0cd98943.chunk.js": "./static/js/3301.0cd98943.chunk.js",
|
9
9
|
"static/css/8148.49dfd2ce.chunk.css": "./static/css/8148.49dfd2ce.chunk.css",
|
10
10
|
"static/js/8148.1b2c085e.chunk.js": "./static/js/8148.1b2c085e.chunk.js",
|
11
11
|
"static/css/5441.e3b876c5.chunk.css": "./static/css/5441.e3b876c5.chunk.css",
|
@@ -38,7 +38,7 @@
|
|
38
38
|
"static/js/3599.565b1eba.chunk.js": "./static/js/3599.565b1eba.chunk.js",
|
39
39
|
"static/js/8691.cb9c04cf.chunk.js": "./static/js/8691.cb9c04cf.chunk.js",
|
40
40
|
"static/js/6718.2e6586ef.chunk.js": "./static/js/6718.2e6586ef.chunk.js",
|
41
|
-
"static/js/7175.
|
41
|
+
"static/js/7175.4cdaec13.chunk.js": "./static/js/7175.4cdaec13.chunk.js",
|
42
42
|
"static/js/5345.73d26e5d.chunk.js": "./static/js/5345.73d26e5d.chunk.js",
|
43
43
|
"static/js/9865.fd93213d.chunk.js": "./static/js/9865.fd93213d.chunk.js",
|
44
44
|
"static/js/6405.ac5a6f23.chunk.js": "./static/js/6405.ac5a6f23.chunk.js",
|
@@ -151,6 +151,6 @@
|
|
151
151
|
},
|
152
152
|
"entrypoints": [
|
153
153
|
"static/css/main.29bca1b5.css",
|
154
|
-
"static/js/main.
|
154
|
+
"static/js/main.8729b772.js"
|
155
155
|
]
|
156
156
|
}
|
streamlit/static/index.html
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.8729b772.js"></script><link href="./static/css/main.29bca1b5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|