# st.connections.SQLConnection

Source: https://docs.streamlit.io/develop/api-reference/connections/st.connections.sqlconnection

> **Tip**
>
> This page only contains the `st.connections.SQLConnection` class. For a deeper dive into creating and managing data connections within Streamlit apps, read [Connecting to data](https://docs.streamlit.io/develop/concepts/connections/connecting-to-data).

* Function signature:

   ```python
   st.connections.SQLConnection(connection_name, **kwargs)
   ```

* Function signature:

   ```python
   SQLConnection.connect()
   ```

* Returns: sqlalchemy.engine.Connection

    A new SQLAlchemy connection object.

* Function signature:

   ```python
   SQLConnection.query(sql, *, show_spinner="Running `sql.query(...)`.", ttl=None, index_col=None, chunksize=None, params=None, **kwargs)
   ```

* Parameters:

   | name | type | default | description |
   |---|---|---|---|
   | sql | str |  | The read-only SQL query to execute. |
   | show_spinner | boolean or string | to | Enable the spinner. The default is to show a spinner when there is a "cache miss" and the cached resource is being created. If a string, the value of the show_spinner param will be used for the spinner text. |
   | ttl | float, int, timedelta or None | None | The maximum number of seconds to keep results in the cache, or None if cached results should not expire. The default is None. |
   | index_col | str, list of str, or None | None | Column(s) to set as index(MultiIndex). Default is None. |
   | chunksize | int or None | None | If specified, return an iterator where chunksize is the number of rows to include in each chunk. Default is None. |
   | params | list, tuple, dict or None | None | List of parameters to pass to the execute method. The syntax used to pass parameters is database driver dependent. Check your database driver documentation for which of the five syntax styles, described in PEP 249 paramstyle, is supported. Default is None. |
   | **kwargs | dict |  | Additional keyword arguments are passed to pandas.read_sql. |

* Returns: pandas.DataFrame

    The result of running the query, formatted as a pandas DataFrame.

* Function signature:

   ```python
   SQLConnection.reset()
   ```

* Function signature:

   ```python
   SQLConnection.driver
   ```

* Returns: str

    The name of the driver. For example, "pyodbc" or "psycopg2".

* Function signature:

   ```python
   SQLConnection.engine
   ```

* Returns: sqlalchemy.engine.base.Engine

    The underlying SQLAlchemy Engine.

* Function signature:

   ```python
   SQLConnection.session
   ```

* Returns: sqlalchemy.orm.Session

    A SQLAlchemy Session.
