streamlit-nightly 1.39.1.dev20241028__py2.py3-none-any.whl → 1.39.1.dev20241030__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.
Files changed (59) hide show
  1. streamlit/connections/base_connection.py +4 -0
  2. streamlit/connections/snowflake_connection.py +310 -36
  3. streamlit/connections/snowpark_connection.py +1 -1
  4. streamlit/connections/sql_connection.py +140 -26
  5. streamlit/proto/MetricsEvent_pb2.py +30 -0
  6. streamlit/proto/MetricsEvent_pb2.pyi +200 -0
  7. streamlit/runtime/connection_factory.py +122 -37
  8. streamlit/static/asset-manifest.json +22 -20
  9. streamlit/static/index.html +1 -1
  10. streamlit/static/static/js/1504.51c32670.chunk.js +2 -0
  11. streamlit/static/static/js/223.7f54d4fe.chunk.js +1 -0
  12. streamlit/static/static/js/2601.677fbaac.chunk.js +1 -0
  13. streamlit/static/static/js/3224.919d670d.chunk.js +1 -0
  14. streamlit/static/static/js/3682.8ecb602d.chunk.js +1 -0
  15. streamlit/static/static/js/3978.58bcc6a4.chunk.js +2 -0
  16. streamlit/static/static/js/4133.5d5fe118.chunk.js +2 -0
  17. streamlit/static/static/js/{4942.e4db7877.chunk.js → 4942.cd41b09c.chunk.js} +1 -1
  18. streamlit/static/static/js/5361.913e291a.chunk.js +1 -0
  19. streamlit/static/static/js/5503.0917ff70.chunk.js +1 -0
  20. streamlit/static/static/js/7612.3f409b56.chunk.js +2 -0
  21. streamlit/static/static/js/783.403d1195.chunk.js +1 -0
  22. streamlit/static/static/js/8148.9b76a4cd.chunk.js +1 -0
  23. streamlit/static/static/js/8237.86c539f3.chunk.js +1 -0
  24. streamlit/static/static/js/8380.9d225c39.chunk.js +1 -0
  25. streamlit/static/static/js/8460.570de48a.chunk.js +1 -0
  26. streamlit/static/static/js/9923.14294b15.chunk.js +1 -0
  27. streamlit/static/static/js/9943.ac0530dc.chunk.js +1 -0
  28. streamlit/static/static/js/main.754d974e.js +28 -0
  29. streamlit/static/static/media/logo.b972e133efb66853e2af89f9219f1069.svg +7 -0
  30. streamlit/web/server/routes.py +1 -0
  31. {streamlit_nightly-1.39.1.dev20241028.dist-info → streamlit_nightly-1.39.1.dev20241030.dist-info}/METADATA +1 -1
  32. {streamlit_nightly-1.39.1.dev20241028.dist-info → streamlit_nightly-1.39.1.dev20241030.dist-info}/RECORD +42 -38
  33. {streamlit_nightly-1.39.1.dev20241028.dist-info → streamlit_nightly-1.39.1.dev20241030.dist-info}/WHEEL +1 -1
  34. streamlit/static/static/js/223.2359dae5.chunk.js +0 -1
  35. streamlit/static/static/js/3224.a04b49ba.chunk.js +0 -1
  36. streamlit/static/static/js/3389.71902a75.chunk.js +0 -1
  37. streamlit/static/static/js/4096.178414b7.chunk.js +0 -2
  38. streamlit/static/static/js/4297.3afbdd03.chunk.js +0 -2
  39. streamlit/static/static/js/4856.03868952.chunk.js +0 -2
  40. streamlit/static/static/js/5849.e92568db.chunk.js +0 -1
  41. streamlit/static/static/js/6198.956025ac.chunk.js +0 -2
  42. streamlit/static/static/js/6360.50be2ff5.chunk.js +0 -1
  43. streamlit/static/static/js/783.788bb3ab.chunk.js +0 -1
  44. streamlit/static/static/js/8148.b29e43b5.chunk.js +0 -1
  45. streamlit/static/static/js/8237.58ae67da.chunk.js +0 -1
  46. streamlit/static/static/js/8460.8b3f792f.chunk.js +0 -1
  47. streamlit/static/static/js/9923.8dc9e5ed.chunk.js +0 -1
  48. streamlit/static/static/js/9943.51b39296.chunk.js +0 -1
  49. streamlit/static/static/js/main.fe594373.js +0 -28
  50. streamlit/static/static/media/logo.83ae4f2fb87e38be7cbb8a5d2beb64d2.svg +0 -5
  51. /streamlit/static/static/css/{4096.8b8f33d6.chunk.css → 1504.8b8f33d6.chunk.css} +0 -0
  52. /streamlit/static/static/js/{4096.178414b7.chunk.js.LICENSE.txt → 1504.51c32670.chunk.js.LICENSE.txt} +0 -0
  53. /streamlit/static/static/js/{6198.956025ac.chunk.js.LICENSE.txt → 3978.58bcc6a4.chunk.js.LICENSE.txt} +0 -0
  54. /streamlit/static/static/js/{4297.3afbdd03.chunk.js.LICENSE.txt → 4133.5d5fe118.chunk.js.LICENSE.txt} +0 -0
  55. /streamlit/static/static/js/{4856.03868952.chunk.js.LICENSE.txt → 7612.3f409b56.chunk.js.LICENSE.txt} +0 -0
  56. /streamlit/static/static/js/{main.fe594373.js.LICENSE.txt → main.754d974e.js.LICENSE.txt} +0 -0
  57. {streamlit_nightly-1.39.1.dev20241028.data → streamlit_nightly-1.39.1.dev20241030.data}/scripts/streamlit.cmd +0 -0
  58. {streamlit_nightly-1.39.1.dev20241028.dist-info → streamlit_nightly-1.39.1.dev20241030.dist-info}/entry_points.txt +0 -0
  59. {streamlit_nightly-1.39.1.dev20241028.dist-info → streamlit_nightly-1.39.1.dev20241030.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,30 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: streamlit/proto/MetricsEvent.proto
4
+ # Protobuf Python Version: 5.26.1
5
+ """Generated protocol buffer code."""
6
+ from google.protobuf import descriptor as _descriptor
7
+ from google.protobuf import descriptor_pool as _descriptor_pool
8
+ from google.protobuf import symbol_database as _symbol_database
9
+ from google.protobuf.internal import builder as _builder
10
+ # @@protoc_insertion_point(imports)
11
+
12
+ _sym_db = _symbol_database.Default()
13
+
14
+
15
+ from streamlit.proto import PageProfile_pb2 as streamlit_dot_proto_dot_PageProfile__pb2
16
+
17
+
18
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\"streamlit/proto/MetricsEvent.proto\x1a!streamlit/proto/PageProfile.proto\"\xea\x06\n\x0cMetricsEvent\x12\r\n\x05\x65vent\x18\x01 \x01(\t\x12\x14\n\x0c\x61nonymous_id\x18\x02 \x01(\t\x12\x15\n\rmachine_id_v3\x18\x03 \x01(\t\x12\x13\n\x0breport_hash\x18\x04 \x01(\t\x12\x0b\n\x03\x64\x65v\x18\x05 \x01(\x08\x12\x0e\n\x06source\x18\x06 \x01(\t\x12\x19\n\x11streamlit_version\x18\x07 \x01(\t\x12\x10\n\x08is_hello\x18\x08 \x01(\x08\x12\x11\n\thosted_at\x18\t \x01(\t\x12\r\n\x05owner\x18\n \x01(\t\x12\x0c\n\x04repo\x18\x0b \x01(\t\x12\x0e\n\x06\x62ranch\x18\x0c \x01(\t\x12\x13\n\x0bmain_module\x18\r \x01(\t\x12\x12\n\ncreator_id\x18\x0e \x01(\t\x12\x18\n\x10\x63ontext_page_url\x18\x0f \x01(\t\x12\x1a\n\x12\x63ontext_page_title\x18\x10 \x01(\t\x12\x19\n\x11\x63ontext_page_path\x18\x11 \x01(\t\x12\x1d\n\x15\x63ontext_page_referrer\x18\x12 \x01(\t\x12\x1b\n\x13\x63ontext_page_search\x18\x13 \x01(\t\x12\x16\n\x0e\x63ontext_locale\x18\x14 \x01(\t\x12\x1a\n\x12\x63ontext_user_agent\x18\x15 \x01(\t\x12\r\n\x05label\x18\x16 \x01(\t\x12\x1a\n\x08\x63ommands\x18\x17 \x03(\x0b\x32\x08.Command\x12\x11\n\texec_time\x18\x18 \x01(\x03\x12\x11\n\tprep_time\x18\x19 \x01(\x03\x12\x0e\n\x06\x63onfig\x18\x1a \x03(\t\x12\x1a\n\x12uncaught_exception\x18\x1b \x01(\t\x12\x14\n\x0c\x61ttributions\x18\x1c \x03(\t\x12\n\n\x02os\x18\x1d \x01(\t\x12\x10\n\x08timezone\x18\x1e \x01(\t\x12\x10\n\x08headless\x18\x1f \x01(\x08\x12\x17\n\x0fis_fragment_run\x18 \x01(\x08\x12\x0e\n\x06\x61pp_id\x18! \x01(\t\x12\x10\n\x08numPages\x18\" \x01(\x03\x12\x12\n\nsession_id\x18# \x01(\t\x12\x16\n\x0epython_version\x18$ \x01(\t\x12\x18\n\x10page_script_hash\x18% \x01(\t\x12\x14\n\x0c\x61\x63tive_theme\x18& \x01(\t\x12\x17\n\x0ftotal_load_time\x18\' \x01(\x03\x12\"\n\x0c\x62rowser_info\x18( \x01(\x0b\x32\x0c.BrowserInfo\"]\n\x0b\x42rowserInfo\x12\x14\n\x0c\x62rowser_name\x18\x01 \x01(\t\x12\x17\n\x0f\x62rowser_version\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65vice_type\x18\x03 \x01(\t\x12\n\n\x02os\x18\x04 \x01(\tB1\n\x1c\x63om.snowflake.apps.streamlitB\x11MetricsEventProtob\x06proto3')
19
+
20
+ _globals = globals()
21
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
22
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'streamlit.proto.MetricsEvent_pb2', _globals)
23
+ if not _descriptor._USE_C_DESCRIPTORS:
24
+ _globals['DESCRIPTOR']._loaded_options = None
25
+ _globals['DESCRIPTOR']._serialized_options = b'\n\034com.snowflake.apps.streamlitB\021MetricsEventProto'
26
+ _globals['_METRICSEVENT']._serialized_start=74
27
+ _globals['_METRICSEVENT']._serialized_end=948
28
+ _globals['_BROWSERINFO']._serialized_start=950
29
+ _globals['_BROWSERINFO']._serialized_end=1043
30
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,200 @@
1
+ """
2
+ @generated by mypy-protobuf. Do not edit manually!
3
+ isort:skip_file
4
+ *!
5
+ Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ """
19
+
20
+ import builtins
21
+ import collections.abc
22
+ import google.protobuf.descriptor
23
+ import google.protobuf.internal.containers
24
+ import google.protobuf.message
25
+ import streamlit.proto.PageProfile_pb2
26
+ import typing
27
+
28
+ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
29
+
30
+ @typing.final
31
+ class MetricsEvent(google.protobuf.message.Message):
32
+ """Metrics events:"""
33
+
34
+ DESCRIPTOR: google.protobuf.descriptor.Descriptor
35
+
36
+ EVENT_FIELD_NUMBER: builtins.int
37
+ ANONYMOUS_ID_FIELD_NUMBER: builtins.int
38
+ MACHINE_ID_V3_FIELD_NUMBER: builtins.int
39
+ REPORT_HASH_FIELD_NUMBER: builtins.int
40
+ DEV_FIELD_NUMBER: builtins.int
41
+ SOURCE_FIELD_NUMBER: builtins.int
42
+ STREAMLIT_VERSION_FIELD_NUMBER: builtins.int
43
+ IS_HELLO_FIELD_NUMBER: builtins.int
44
+ HOSTED_AT_FIELD_NUMBER: builtins.int
45
+ OWNER_FIELD_NUMBER: builtins.int
46
+ REPO_FIELD_NUMBER: builtins.int
47
+ BRANCH_FIELD_NUMBER: builtins.int
48
+ MAIN_MODULE_FIELD_NUMBER: builtins.int
49
+ CREATOR_ID_FIELD_NUMBER: builtins.int
50
+ CONTEXT_PAGE_URL_FIELD_NUMBER: builtins.int
51
+ CONTEXT_PAGE_TITLE_FIELD_NUMBER: builtins.int
52
+ CONTEXT_PAGE_PATH_FIELD_NUMBER: builtins.int
53
+ CONTEXT_PAGE_REFERRER_FIELD_NUMBER: builtins.int
54
+ CONTEXT_PAGE_SEARCH_FIELD_NUMBER: builtins.int
55
+ CONTEXT_LOCALE_FIELD_NUMBER: builtins.int
56
+ CONTEXT_USER_AGENT_FIELD_NUMBER: builtins.int
57
+ LABEL_FIELD_NUMBER: builtins.int
58
+ COMMANDS_FIELD_NUMBER: builtins.int
59
+ EXEC_TIME_FIELD_NUMBER: builtins.int
60
+ PREP_TIME_FIELD_NUMBER: builtins.int
61
+ CONFIG_FIELD_NUMBER: builtins.int
62
+ UNCAUGHT_EXCEPTION_FIELD_NUMBER: builtins.int
63
+ ATTRIBUTIONS_FIELD_NUMBER: builtins.int
64
+ OS_FIELD_NUMBER: builtins.int
65
+ TIMEZONE_FIELD_NUMBER: builtins.int
66
+ HEADLESS_FIELD_NUMBER: builtins.int
67
+ IS_FRAGMENT_RUN_FIELD_NUMBER: builtins.int
68
+ APP_ID_FIELD_NUMBER: builtins.int
69
+ NUMPAGES_FIELD_NUMBER: builtins.int
70
+ SESSION_ID_FIELD_NUMBER: builtins.int
71
+ PYTHON_VERSION_FIELD_NUMBER: builtins.int
72
+ PAGE_SCRIPT_HASH_FIELD_NUMBER: builtins.int
73
+ ACTIVE_THEME_FIELD_NUMBER: builtins.int
74
+ TOTAL_LOAD_TIME_FIELD_NUMBER: builtins.int
75
+ BROWSER_INFO_FIELD_NUMBER: builtins.int
76
+ event: builtins.str
77
+ """Common Event Fields:"""
78
+ anonymous_id: builtins.str
79
+ machine_id_v3: builtins.str
80
+ report_hash: builtins.str
81
+ dev: builtins.bool
82
+ source: builtins.str
83
+ streamlit_version: builtins.str
84
+ is_hello: builtins.bool
85
+ hosted_at: builtins.str
86
+ """Host tracking fields:"""
87
+ owner: builtins.str
88
+ repo: builtins.str
89
+ branch: builtins.str
90
+ main_module: builtins.str
91
+ creator_id: builtins.str
92
+ context_page_url: builtins.str
93
+ """Context fields:"""
94
+ context_page_title: builtins.str
95
+ context_page_path: builtins.str
96
+ context_page_referrer: builtins.str
97
+ context_page_search: builtins.str
98
+ context_locale: builtins.str
99
+ context_user_agent: builtins.str
100
+ label: builtins.str
101
+ """Menu Click Event field:"""
102
+ exec_time: builtins.int
103
+ prep_time: builtins.int
104
+ uncaught_exception: builtins.str
105
+ os: builtins.str
106
+ timezone: builtins.str
107
+ headless: builtins.bool
108
+ is_fragment_run: builtins.bool
109
+ app_id: builtins.str
110
+ """Addtl for page profile metrics"""
111
+ numPages: builtins.int
112
+ session_id: builtins.str
113
+ python_version: builtins.str
114
+ page_script_hash: builtins.str
115
+ active_theme: builtins.str
116
+ total_load_time: builtins.int
117
+ @property
118
+ def commands(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[streamlit.proto.PageProfile_pb2.Command]:
119
+ """Page Profile Event fields:
120
+ Same as PageProfile msg
121
+ """
122
+
123
+ @property
124
+ def config(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ...
125
+ @property
126
+ def attributions(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ...
127
+ @property
128
+ def browser_info(self) -> global___BrowserInfo: ...
129
+ def __init__(
130
+ self,
131
+ *,
132
+ event: builtins.str = ...,
133
+ anonymous_id: builtins.str = ...,
134
+ machine_id_v3: builtins.str = ...,
135
+ report_hash: builtins.str = ...,
136
+ dev: builtins.bool = ...,
137
+ source: builtins.str = ...,
138
+ streamlit_version: builtins.str = ...,
139
+ is_hello: builtins.bool = ...,
140
+ hosted_at: builtins.str = ...,
141
+ owner: builtins.str = ...,
142
+ repo: builtins.str = ...,
143
+ branch: builtins.str = ...,
144
+ main_module: builtins.str = ...,
145
+ creator_id: builtins.str = ...,
146
+ context_page_url: builtins.str = ...,
147
+ context_page_title: builtins.str = ...,
148
+ context_page_path: builtins.str = ...,
149
+ context_page_referrer: builtins.str = ...,
150
+ context_page_search: builtins.str = ...,
151
+ context_locale: builtins.str = ...,
152
+ context_user_agent: builtins.str = ...,
153
+ label: builtins.str = ...,
154
+ commands: collections.abc.Iterable[streamlit.proto.PageProfile_pb2.Command] | None = ...,
155
+ exec_time: builtins.int = ...,
156
+ prep_time: builtins.int = ...,
157
+ config: collections.abc.Iterable[builtins.str] | None = ...,
158
+ uncaught_exception: builtins.str = ...,
159
+ attributions: collections.abc.Iterable[builtins.str] | None = ...,
160
+ os: builtins.str = ...,
161
+ timezone: builtins.str = ...,
162
+ headless: builtins.bool = ...,
163
+ is_fragment_run: builtins.bool = ...,
164
+ app_id: builtins.str = ...,
165
+ numPages: builtins.int = ...,
166
+ session_id: builtins.str = ...,
167
+ python_version: builtins.str = ...,
168
+ page_script_hash: builtins.str = ...,
169
+ active_theme: builtins.str = ...,
170
+ total_load_time: builtins.int = ...,
171
+ browser_info: global___BrowserInfo | None = ...,
172
+ ) -> None: ...
173
+ def HasField(self, field_name: typing.Literal["browser_info", b"browser_info"]) -> builtins.bool: ...
174
+ def ClearField(self, field_name: typing.Literal["active_theme", b"active_theme", "anonymous_id", b"anonymous_id", "app_id", b"app_id", "attributions", b"attributions", "branch", b"branch", "browser_info", b"browser_info", "commands", b"commands", "config", b"config", "context_locale", b"context_locale", "context_page_path", b"context_page_path", "context_page_referrer", b"context_page_referrer", "context_page_search", b"context_page_search", "context_page_title", b"context_page_title", "context_page_url", b"context_page_url", "context_user_agent", b"context_user_agent", "creator_id", b"creator_id", "dev", b"dev", "event", b"event", "exec_time", b"exec_time", "headless", b"headless", "hosted_at", b"hosted_at", "is_fragment_run", b"is_fragment_run", "is_hello", b"is_hello", "label", b"label", "machine_id_v3", b"machine_id_v3", "main_module", b"main_module", "numPages", b"numPages", "os", b"os", "owner", b"owner", "page_script_hash", b"page_script_hash", "prep_time", b"prep_time", "python_version", b"python_version", "repo", b"repo", "report_hash", b"report_hash", "session_id", b"session_id", "source", b"source", "streamlit_version", b"streamlit_version", "timezone", b"timezone", "total_load_time", b"total_load_time", "uncaught_exception", b"uncaught_exception"]) -> None: ...
175
+
176
+ global___MetricsEvent = MetricsEvent
177
+
178
+ @typing.final
179
+ class BrowserInfo(google.protobuf.message.Message):
180
+ DESCRIPTOR: google.protobuf.descriptor.Descriptor
181
+
182
+ BROWSER_NAME_FIELD_NUMBER: builtins.int
183
+ BROWSER_VERSION_FIELD_NUMBER: builtins.int
184
+ DEVICE_TYPE_FIELD_NUMBER: builtins.int
185
+ OS_FIELD_NUMBER: builtins.int
186
+ browser_name: builtins.str
187
+ browser_version: builtins.str
188
+ device_type: builtins.str
189
+ os: builtins.str
190
+ def __init__(
191
+ self,
192
+ *,
193
+ browser_name: builtins.str = ...,
194
+ browser_version: builtins.str = ...,
195
+ device_type: builtins.str = ...,
196
+ os: builtins.str = ...,
197
+ ) -> None: ...
198
+ def ClearField(self, field_name: typing.Literal["browser_name", b"browser_name", "browser_version", b"browser_version", "device_type", b"device_type", "os", b"os"]) -> None: ...
199
+
200
+ global___BrowserInfo = BrowserInfo
@@ -211,76 +211,161 @@ def connection_factory(
211
211
  ):
212
212
  """Create a new connection to a data store or API, or return an existing one.
213
213
 
214
- Config options, credentials, secrets, etc. for connections are taken from various
215
- sources:
214
+ Configuration options, credentials, and secrets for connections are
215
+ combined from the following sources:
216
216
 
217
+ - The keyword arguments passed to this command.
218
+ - The app's ``secrets.toml`` files.
217
219
  - Any connection-specific configuration files.
218
- - An app's ``secrets.toml`` files.
219
- - The kwargs passed to this function.
220
+
221
+ The connection returned from ``st.connection`` is internally cached with
222
+ ``st.cache_resource`` and is therefore shared between sessions.
220
223
 
221
224
  Parameters
222
225
  ----------
223
226
  name : str
224
- The connection name used for secrets lookup in ``[connections.<name>]``.
225
- Type will be inferred from passing ``"sql"``, ``"snowflake"``, or ``"snowpark"``.
227
+ The connection name used for secrets lookup in ``secrets.toml``.
228
+ Streamlit uses secrets under ``[connections.<name>]`` for the
229
+ connection. ``type`` will be inferred if ``name`` is one of the
230
+ following: ``"snowflake"``, ``"snowpark"``, or ``"sql"``.
231
+
226
232
  type : str, connection class, or None
227
- The type of connection to create. It can be a keyword (``"sql"``, ``"snowflake"``,
228
- or ``"snowpark"``), a path to an importable class, or an imported class reference.
229
- All classes must extend ``st.connections.BaseConnection`` and implement the
230
- ``_connect()`` method. If the type kwarg is None, a ``type`` field must be set in
231
- the connection's section in ``secrets.toml``.
233
+ The type of connection to create. This can be one of the following:
234
+
235
+ - ``None`` (default): Streamlit will infer the connection type from
236
+ ``name``. If the type is not inferrable from ``name``, the type must
237
+ be specified in ``secrets.toml`` instead.
238
+ - ``"snowflake"``: Streamlit will initialize a connection with
239
+ |SnowflakeConnection|_.
240
+ - ``"snowpark"``: Streamlit will initialize a connection with
241
+ |SnowparkConnection|_. This is deprecated.
242
+ - ``"sql"``: Streamlit will initialize a connection with
243
+ |SQLConnection|_.
244
+ - A string path to an importable class: This must be a dot-separated
245
+ module path ending in the importable class. Streamlit will import the
246
+ class and initialize a connection with it. The class must extend
247
+ ``st.connections.BaseConnection``.
248
+ - An imported class reference: Streamlit will initialize a connection
249
+ with the referenced class, which must extend
250
+ ``st.connections.BaseConnection``.
251
+
252
+ .. |SnowflakeConnection| replace:: ``SnowflakeConnection``
253
+ .. _SnowflakeConnection: https://docs.streamlit.io/develop/api-reference/connections/st.connections.snowflakeconnection
254
+ .. |SnowparkConnection| replace:: ``SnowparkConnection``
255
+ .. _SnowparkConnection: https://docs.streamlit.io/develop/api-reference/connections/st.connections.snowparkconnection
256
+ .. |SQLConnection| replace:: ``SQLConnection``
257
+ .. _SQLConnection: https://docs.streamlit.io/develop/api-reference/connections/st.connections.sqlconnection
258
+
232
259
  max_entries : int or None
233
- The maximum number of connections to keep in the cache, or None
234
- for an unbounded cache. (When a new entry is added to a full cache,
235
- the oldest cached entry will be removed.) The default is None.
260
+ The maximum number of connections to keep in the cache.
261
+ If this is ``None`` (default), the cache is unbounded. Otherwise, when
262
+ a new entry is added to a full cache, the oldest cached entry is
263
+ removed.
236
264
  ttl : float, timedelta, or None
237
- The maximum number of seconds to keep results in the cache, or
238
- None if cached results should not expire. The default is None.
265
+ The maximum number of seconds to keep results in the cache.
266
+ If this is ``None`` (default), cached results do not expire with time.
239
267
  **kwargs : any
240
- Additional connection specific kwargs that are passed to the Connection's
241
- ``_connect()`` method. Learn more from the specific Connection's documentation.
268
+ Connection-specific keyword arguments that are passed to the
269
+ connection's ``._connect()`` method. ``**kwargs`` are typically
270
+ combined with (and take precendence over) key-value pairs in
271
+ ``secrets.toml``. To learn more, see the specific connection's
272
+ documentation.
242
273
 
243
274
  Returns
244
275
  -------
245
- Connection object
246
- An initialized Connection object of the specified type.
276
+ Subclass of BaseConnection
277
+ An initialized connection object of the specified ``type``.
247
278
 
248
279
  Examples
249
280
  --------
281
+
282
+ **Example 1: Inferred connection type**
283
+
250
284
  The easiest way to create a first-party (SQL, Snowflake, or Snowpark) connection is
251
285
  to use their default names and define corresponding sections in your ``secrets.toml``
252
- file.
286
+ file. The following example creates a ``"sql"``-type connection.
253
287
 
254
- >>> import streamlit as st
255
- >>> conn = st.connection("sql") # [connections.sql] section in secrets.toml.
288
+ ``.streamlit/secrets.toml``:
289
+
290
+ >>> [connections.sql]
291
+ >>> dialect = "xxx"
292
+ >>> host = "xxx"
293
+ >>> username = "xxx"
294
+ >>> password = "xxx"
256
295
 
257
- Creating a SQLConnection with a custom name requires you to explicitly specify the
258
- type. If type is not passed as a kwarg, it must be set in the appropriate section of
259
- ``secrets.toml``.
296
+ Your app code:
297
+
298
+ >>> import streamlit as st
299
+ >>> conn = st.connection("sql")
300
+
301
+ **Example 2: Named connections**
302
+
303
+ Creating a connection with a custom name requires you to explicitly
304
+ specify the type. If ``type`` is not passed as a keyword argument, it must
305
+ be set in the appropriate section of ``secrets.toml``. The following
306
+ example creates two ``"sql"``-type connections, each with their own
307
+ custom name. The first defines ``type`` in the ``st.connection`` command;
308
+ the second defines ``type`` in ``secrets.toml``.
309
+
310
+ ``.streamlit/secrets.toml``:
311
+
312
+ >>> [connections.first_connection]
313
+ >>> dialect = "xxx"
314
+ >>> host = "xxx"
315
+ >>> username = "xxx"
316
+ >>> password = "xxx"
317
+ >>>
318
+ >>> [connections.second_connection]
319
+ >>> type = "sql"
320
+ >>> dialect = "yyy"
321
+ >>> host = "yyy"
322
+ >>> username = "yyy"
323
+ >>> password = "yyy"
324
+
325
+ Your app code:
260
326
 
261
327
  >>> import streamlit as st
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].
328
+ >>> conn1 = st.connection("first_connection", type="sql")
329
+ >>> conn2 = st.connection("second_connection")
268
330
 
269
- Passing the full module path to the connection class that you want to use can be
270
- useful, especially when working with a custom connection:
331
+ **Example 3: Using a path to the connection class**
332
+
333
+ Passing the full module path to the connection class can be useful,
334
+ especially when working with a custom connection. Although this is not the
335
+ typical way to create first party connections, the following example
336
+ creates the same type of connection as one with ``type="sql"``. Note that
337
+ ``type`` is a string path.
338
+
339
+ ``.streamlit/secrets.toml``:
340
+
341
+ >>> [connections.my_sql_connection]
342
+ >>> url = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"
343
+
344
+ Your app code:
271
345
 
272
346
  >>> import streamlit as st
273
347
  >>> conn = st.connection(
274
348
  ... "my_sql_connection", type="streamlit.connections.SQLConnection"
275
349
  ... )
276
350
 
277
- Finally, you can pass the connection class to use directly to this function. Doing
278
- so allows static type checking tools such as ``mypy`` to infer the exact return
279
- type of ``st.connection``.
351
+ **Example 4: Importing the connection class**
352
+
353
+ You can pass the connection class directly to the ``st.connection``
354
+ command. Doing so allows static type checking tools such as ``mypy`` to
355
+ infer the exact return type of ``st.connection``. The following example
356
+ creates the same connection as in Example 3.
357
+
358
+ ``.streamlit/secrets.toml``:
359
+
360
+ >>> [connections.my_sql_connection]
361
+ >>> url = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"
362
+
363
+ Your app code:
280
364
 
281
365
  >>> import streamlit as st
282
366
  >>> from streamlit.connections import SQLConnection
283
367
  >>> conn = st.connection("my_sql_connection", type=SQLConnection)
368
+
284
369
  """
285
370
  USE_ENV_PREFIX = "env:"
286
371
 
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.a1bc16b2.css",
4
- "main.js": "./static/js/main.fe594373.js",
4
+ "main.js": "./static/js/main.754d974e.js",
5
5
  "static/js/6679.265ca09c.chunk.js": "./static/js/6679.265ca09c.chunk.js",
6
6
  "static/js/9464.7e9a3c0a.chunk.js": "./static/js/9464.7e9a3c0a.chunk.js",
7
7
  "static/js/9077.721329d6.chunk.js": "./static/js/9077.721329d6.chunk.js",
8
8
  "static/js/3391.7aba08a0.chunk.js": "./static/js/3391.7aba08a0.chunk.js",
9
9
  "static/css/9943.d452238e.chunk.css": "./static/css/9943.d452238e.chunk.css",
10
- "static/js/9943.51b39296.chunk.js": "./static/js/9943.51b39296.chunk.js",
11
- "static/js/8460.8b3f792f.chunk.js": "./static/js/8460.8b3f792f.chunk.js",
10
+ "static/js/9943.ac0530dc.chunk.js": "./static/js/9943.ac0530dc.chunk.js",
11
+ "static/js/8460.570de48a.chunk.js": "./static/js/8460.570de48a.chunk.js",
12
12
  "static/js/3861.867f8617.chunk.js": "./static/js/3861.867f8617.chunk.js",
13
13
  "static/js/8642.58110d15.chunk.js": "./static/js/8642.58110d15.chunk.js",
14
- "static/js/223.2359dae5.chunk.js": "./static/js/223.2359dae5.chunk.js",
15
- "static/js/8148.b29e43b5.chunk.js": "./static/js/8148.b29e43b5.chunk.js",
14
+ "static/js/223.7f54d4fe.chunk.js": "./static/js/223.7f54d4fe.chunk.js",
15
+ "static/js/8148.9b76a4cd.chunk.js": "./static/js/8148.9b76a4cd.chunk.js",
16
16
  "static/js/84.414fa87b.chunk.js": "./static/js/84.414fa87b.chunk.js",
17
- "static/js/9923.8dc9e5ed.chunk.js": "./static/js/9923.8dc9e5ed.chunk.js",
17
+ "static/js/9923.14294b15.chunk.js": "./static/js/9923.14294b15.chunk.js",
18
18
  "static/js/583.61ac7fde.chunk.js": "./static/js/583.61ac7fde.chunk.js",
19
19
  "static/js/4827.bf6d34b0.chunk.js": "./static/js/4827.bf6d34b0.chunk.js",
20
- "static/js/8237.58ae67da.chunk.js": "./static/js/8237.58ae67da.chunk.js",
20
+ "static/js/8237.86c539f3.chunk.js": "./static/js/8237.86c539f3.chunk.js",
21
21
  "static/js/5828.f8572ba4.chunk.js": "./static/js/5828.f8572ba4.chunk.js",
22
- "static/js/3224.a04b49ba.chunk.js": "./static/js/3224.a04b49ba.chunk.js",
22
+ "static/js/3224.919d670d.chunk.js": "./static/js/3224.919d670d.chunk.js",
23
23
  "static/js/9060.1ec8dc2b.chunk.js": "./static/js/9060.1ec8dc2b.chunk.js",
24
24
  "static/js/5625.a2d9a416.chunk.js": "./static/js/5625.a2d9a416.chunk.js",
25
25
  "static/js/6141.d2879825.chunk.js": "./static/js/6141.d2879825.chunk.js",
@@ -27,7 +27,7 @@
27
27
  "static/js/1086.93ecee4c.chunk.js": "./static/js/1086.93ecee4c.chunk.js",
28
28
  "static/js/245.f99a075b.chunk.js": "./static/js/245.f99a075b.chunk.js",
29
29
  "static/js/7193.534e7da1.chunk.js": "./static/js/7193.534e7da1.chunk.js",
30
- "static/js/6360.50be2ff5.chunk.js": "./static/js/6360.50be2ff5.chunk.js",
30
+ "static/js/3682.8ecb602d.chunk.js": "./static/js/3682.8ecb602d.chunk.js",
31
31
  "static/js/8790.0b98f286.chunk.js": "./static/js/8790.0b98f286.chunk.js",
32
32
  "static/js/8815.304ea46a.chunk.js": "./static/js/8815.304ea46a.chunk.js",
33
33
  "static/js/9528.a58c0ad2.chunk.js": "./static/js/9528.a58c0ad2.chunk.js",
@@ -48,21 +48,23 @@
48
48
  "static/js/7983.15bb2017.chunk.js": "./static/js/7983.15bb2017.chunk.js",
49
49
  "static/js/8648.92079acf.chunk.js": "./static/js/8648.92079acf.chunk.js",
50
50
  "static/js/766.e3700e32.chunk.js": "./static/js/766.e3700e32.chunk.js",
51
- "static/js/783.788bb3ab.chunk.js": "./static/js/783.788bb3ab.chunk.js",
52
- "static/js/5849.e92568db.chunk.js": "./static/js/5849.e92568db.chunk.js",
53
- "static/css/4096.8b8f33d6.chunk.css": "./static/css/4096.8b8f33d6.chunk.css",
54
- "static/js/4096.178414b7.chunk.js": "./static/js/4096.178414b7.chunk.js",
55
- "static/js/4856.03868952.chunk.js": "./static/js/4856.03868952.chunk.js",
56
- "static/js/3389.71902a75.chunk.js": "./static/js/3389.71902a75.chunk.js",
57
- "static/js/4297.3afbdd03.chunk.js": "./static/js/4297.3afbdd03.chunk.js",
58
- "static/js/4942.e4db7877.chunk.js": "./static/js/4942.e4db7877.chunk.js",
51
+ "static/js/783.403d1195.chunk.js": "./static/js/783.403d1195.chunk.js",
52
+ "static/js/2601.677fbaac.chunk.js": "./static/js/2601.677fbaac.chunk.js",
53
+ "static/css/1504.8b8f33d6.chunk.css": "./static/css/1504.8b8f33d6.chunk.css",
54
+ "static/js/1504.51c32670.chunk.js": "./static/js/1504.51c32670.chunk.js",
55
+ "static/js/7612.3f409b56.chunk.js": "./static/js/7612.3f409b56.chunk.js",
56
+ "static/js/5361.913e291a.chunk.js": "./static/js/5361.913e291a.chunk.js",
57
+ "static/js/4133.5d5fe118.chunk.js": "./static/js/4133.5d5fe118.chunk.js",
58
+ "static/js/4942.cd41b09c.chunk.js": "./static/js/4942.cd41b09c.chunk.js",
59
59
  "static/js/9993.5b55b4c2.chunk.js": "./static/js/9993.5b55b4c2.chunk.js",
60
60
  "static/js/2627.2462a014.chunk.js": "./static/js/2627.2462a014.chunk.js",
61
61
  "static/js/5764.5a55e5be.chunk.js": "./static/js/5764.5a55e5be.chunk.js",
62
62
  "static/js/797.36f1bf7d.chunk.js": "./static/js/797.36f1bf7d.chunk.js",
63
- "static/js/6198.956025ac.chunk.js": "./static/js/6198.956025ac.chunk.js",
64
63
  "static/js/1674.86aea8e0.chunk.js": "./static/js/1674.86aea8e0.chunk.js",
64
+ "static/js/3978.58bcc6a4.chunk.js": "./static/js/3978.58bcc6a4.chunk.js",
65
65
  "static/js/7591.b3928443.chunk.js": "./static/js/7591.b3928443.chunk.js",
66
+ "static/js/8380.9d225c39.chunk.js": "./static/js/8380.9d225c39.chunk.js",
67
+ "static/js/5503.0917ff70.chunk.js": "./static/js/5503.0917ff70.chunk.js",
66
68
  "static/media/MaterialSymbols-Rounded.woff2": "./static/media/MaterialSymbols-Rounded.ec07649f7a20048d5730.woff2",
67
69
  "static/media/fireworks.gif": "./static/media/fireworks.0906f02ea43f1018a6d2.gif",
68
70
  "static/media/flake-2.png": "./static/media/flake-2.e3f07d06933dd0e84c24.png",
@@ -148,13 +150,13 @@
148
150
  "static/media/KaTeX_Size3-Regular.woff": "./static/media/KaTeX_Size3-Regular.7947224e8a9914fa332b.woff",
149
151
  "static/media/KaTeX_Size3-Regular.woff2": "./static/media/KaTeX_Size3-Regular.e1951519f6f0596f7356.woff2",
150
152
  "static/media/rocket.svg": "./static/media/rocket.add69fb2c850b62fa60077e3a5a06d28.svg",
153
+ "static/media/logo.svg": "./static/media/logo.b972e133efb66853e2af89f9219f1069.svg",
151
154
  "static/media/streamlit-mark-color.svg": "./static/media/streamlit-mark-color.e5952193e5f735a3afb01a78a4dd4b41.svg",
152
- "static/media/logo.svg": "./static/media/logo.83ae4f2fb87e38be7cbb8a5d2beb64d2.svg",
153
155
  "index.html": "./index.html",
154
156
  "static/media/checkmark.svg": "./static/media/checkmark.29851c8e9e6ef0c3d6c1e4efe3c1bb9e.svg"
155
157
  },
156
158
  "entrypoints": [
157
159
  "static/css/main.a1bc16b2.css",
158
- "static/js/main.fe594373.js"
160
+ "static/js/main.754d974e.js"
159
161
  ]
160
162
  }
@@ -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.fe594373.js"></script><link href="./static/css/main.a1bc16b2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
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.754d974e.js"></script><link href="./static/css/main.a1bc16b2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>