Retrieving data from Postgres DB gives serialization error

I am trying to get data from postgres db. Here is my code. I receive serialization error along with cache error. Error stack trace added after code

Python Version - 3.12
Streamli Version - 1.31.1
psycopg2-binary - 2.9.9
SQLAlchemy - 2.0.27

import streamlit as st

# Config section defined in [connections.sql] in secrets.toml.
# Create the SQL connection to db as specified in your secrets file.
conn = st.connection('restaurant_dev', type='sql')
st.write(conn)
# Perform query.
df = conn.query('SELECT * FROM public.restaurant')
st.dataframe(df)

Error message

^C  Stopping...
(venv) Brocks-MacBook-Pro:streamlittdemo brocklunardi$  streamlit run main.py

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://10.0.0.163:8501

  For better performance, install the Watchdog module:

  $ xcode-select --install
  $ pip install watchdog
            
2024-02-27 16:25:53.960 Uncaught app exception
Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 698, in write_result
    pickled_entry = pickle.dumps(multi_cache_results)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle memoryview objects

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 330, in _handle_cache_miss
    cache.write_result(value_key, computed_value, messages)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 397, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 700, in write_result
    raise CacheError(f"Failed to pickle {key}") from exc
streamlit.runtime.caching.cache_errors.CacheError: Failed to pickle d279208d9cd381546cfd8d85c1b9c7c2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/main.py", line 8, in <module>
    df = conn.query('SELECT * FROM public.restaurant')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/connections/sql_connection.py", line 238, in query
    return _query(
           ^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
    return cached_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
    return self._get_or_create_cached_value(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 268, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 346, in _handle_cache_miss
    raise UnserializableReturnValueError(
streamlit.runtime.caching.cache_errors.UnserializableReturnValueError: 
            Cannot serialize the return value (of type `pandas.core.frame.DataFrame`) in `_query()`.
            `st.cache_data` uses [pickle](https://docs.python.org/3/library/pickle.html) to
            serialize the function’s return value and safely store it in the cache without mutating the original object. Please convert the return value to a pickle-serializable type.
            If you want to cache unserializable objects such as database connections or Tensorflow
            sessions, use `st.cache_resource` instead (see [our docs](https://docs.streamlit.io/library/advanced-features/caching) for differences).
2024-02-27 16:25:54.327 Uncaught app exception
Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 698, in write_result
    pickled_entry = pickle.dumps(multi_cache_results)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle memoryview objects

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 330, in _handle_cache_miss
    cache.write_result(value_key, computed_value, messages)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 397, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 700, in write_result
    raise CacheError(f"Failed to pickle {key}") from exc
streamlit.runtime.caching.cache_errors.CacheError: Failed to pickle d279208d9cd381546cfd8d85c1b9c7c2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/main.py", line 8, in <module>
    df = conn.query('SELECT * FROM public.restaurant')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/connections/sql_connection.py", line 238, in query
    return _query(
           ^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
    return cached_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
    return self._get_or_create_cached_value(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 268, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 346, in _handle_cache_miss
    raise UnserializableReturnValueError(
streamlit.runtime.caching.cache_errors.UnserializableReturnValueError: 
            Cannot serialize the return value (of type `pandas.core.frame.DataFrame`) in `_query()`.
            `st.cache_data` uses [pickle](https://docs.python.org/3/library/pickle.html) to
            serialize the function’s return value and safely store it in the cache without mutating the original object. Please convert the return value to a pickle-serializable type.
            If you want to cache unserializable objects such as database connections or Tensorflow
            sessions, use `st.cache_resource` instead (see [our docs](https://docs.streamlit.io/library/advanced-features/caching) for differences).
2024-02-27 16:25:54.413 Uncaught app exception
Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 698, in write_result
    pickled_entry = pickle.dumps(multi_cache_results)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle memoryview objects

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 330, in _handle_cache_miss
    cache.write_result(value_key, computed_value, messages)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 397, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 700, in write_result
    raise CacheError(f"Failed to pickle {key}") from exc
streamlit.runtime.caching.cache_errors.CacheError: Failed to pickle d279208d9cd381546cfd8d85c1b9c7c2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/main.py", line 8, in <module>
    df = conn.query('SELECT * FROM public.restaurant')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/connections/sql_connection.py", line 238, in query
    return _query(
           ^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
    return cached_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
    return self._get_or_create_cached_value(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 268, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 346, in _handle_cache_miss
    raise UnserializableReturnValueError(
streamlit.runtime.caching.cache_errors.UnserializableReturnValueError: 
            Cannot serialize the return value (of type `pandas.core.frame.DataFrame`) in `_query()`.
            `st.cache_data` uses [pickle](https://docs.python.org/3/library/pickle.html) to
            serialize the function’s return value and safely store it in the cache without mutating the original object. Please convert the return value to a pickle-serializable type.
            If you want to cache unserializable objects such as database connections or Tensorflow
            sessions, use `st.cache_resource` instead (see [our docs](https://docs.streamlit.io/library/advanced-features/caching) for differences).
2024-02-27 16:25:54.777 Uncaught app exception
Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 698, in write_result
    pickled_entry = pickle.dumps(multi_cache_results)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle memoryview objects

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 330, in _handle_cache_miss
    cache.write_result(value_key, computed_value, messages)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 397, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 700, in write_result
    raise CacheError(f"Failed to pickle {key}") from exc
streamlit.runtime.caching.cache_errors.CacheError: Failed to pickle d279208d9cd381546cfd8d85c1b9c7c2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/main.py", line 8, in <module>
    df = conn.query('SELECT * FROM public.restaurant')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/connections/sql_connection.py", line 238, in query
    return _query(
           ^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
    return cached_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
    return self._get_or_create_cached_value(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 268, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 346, in _handle_cache_miss
    raise UnserializableReturnValueError(
streamlit.runtime.caching.cache_errors.UnserializableReturnValueError: 
            Cannot serialize the return value (of type `pandas.core.frame.DataFrame`) in `_query()`.
            `st.cache_data` uses [pickle](https://docs.python.org/3/library/pickle.html) to
            serialize the function’s return value and safely store it in the cache without mutating the original object. Please convert the return value to a pickle-serializable type.
            If you want to cache unserializable objects such as database connections or Tensorflow
            sessions, use `st.cache_resource` instead (see [our docs](https://docs.streamlit.io/library/advanced-features/caching) for differences).
2024-02-27 16:25:54.859 Uncaught app exception
Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 698, in write_result
    pickled_entry = pickle.dumps(multi_cache_results)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle memoryview objects

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 330, in _handle_cache_miss
    cache.write_result(value_key, computed_value, messages)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 397, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 700, in write_result
    raise CacheError(f"Failed to pickle {key}") from exc
streamlit.runtime.caching.cache_errors.CacheError: Failed to pickle d279208d9cd381546cfd8d85c1b9c7c2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/main.py", line 8, in <module>
    df = conn.query('SELECT * FROM public.restaurant')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/connections/sql_connection.py", line 238, in query
    return _query(
           ^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
    return cached_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
    return self._get_or_create_cached_value(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 268, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 346, in _handle_cache_miss
    raise UnserializableReturnValueError(
streamlit.runtime.caching.cache_errors.UnserializableReturnValueError: 
            Cannot serialize the return value (of type `pandas.core.frame.DataFrame`) in `_query()`.
            `st.cache_data` uses [pickle](https://docs.python.org/3/library/pickle.html) to
            serialize the function’s return value and safely store it in the cache without mutating the original object. Please convert the return value to a pickle-serializable type.
            If you want to cache unserializable objects such as database connections or Tensorflow
            sessions, use `st.cache_resource` instead (see [our docs](https://docs.streamlit.io/library/advanced-features/caching) for differences).
2024-02-27 16:25:54.936 Uncaught app exception
Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 698, in write_result
    pickled_entry = pickle.dumps(multi_cache_results)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle memoryview objects

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 330, in _handle_cache_miss
    cache.write_result(value_key, computed_value, messages)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 397, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 700, in write_result
    raise CacheError(f"Failed to pickle {key}") from exc
streamlit.runtime.caching.cache_errors.CacheError: Failed to pickle d279208d9cd381546cfd8d85c1b9c7c2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/main.py", line 8, in <module>
    df = conn.query('SELECT * FROM public.restaurant')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/connections/sql_connection.py", line 238, in query
    return _query(
           ^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
    return cached_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
    return self._get_or_create_cached_value(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 268, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 346, in _handle_cache_miss
    raise UnserializableReturnValueError(
streamlit.runtime.caching.cache_errors.UnserializableReturnValueError: 
            Cannot serialize the return value (of type `pandas.core.frame.DataFrame`) in `_query()`.
            `st.cache_data` uses [pickle](https://docs.python.org/3/library/pickle.html) to
            serialize the function’s return value and safely store it in the cache without mutating the original object. Please convert the return value to a pickle-serializable type.
            If you want to cache unserializable objects such as database connections or Tensorflow
            sessions, use `st.cache_resource` instead (see [our docs](https://docs.streamlit.io/library/advanced-features/caching) for differences).
2024-02-27 16:25:55.027 Uncaught app exception
Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 698, in write_result
    pickled_entry = pickle.dumps(multi_cache_results)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle memoryview objects

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 330, in _handle_cache_miss
    cache.write_result(value_key, computed_value, messages)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 397, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 700, in write_result
    raise CacheError(f"Failed to pickle {key}") from exc
streamlit.runtime.caching.cache_errors.CacheError: Failed to pickle d279208d9cd381546cfd8d85c1b9c7c2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/main.py", line 8, in <module>
    df = conn.query('SELECT * FROM public.restaurant')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/connections/sql_connection.py", line 238, in query
    return _query(
           ^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
    return cached_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
    return self._get_or_create_cached_value(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 268, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 346, in _handle_cache_miss
    raise UnserializableReturnValueError(
streamlit.runtime.caching.cache_errors.UnserializableReturnValueError: 
            Cannot serialize the return value (of type `pandas.core.frame.DataFrame`) in `_query()`.
            `st.cache_data` uses [pickle](https://docs.python.org/3/library/pickle.html) to
            serialize the function’s return value and safely store it in the cache without mutating the original object. Please convert the return value to a pickle-serializable type.
            If you want to cache unserializable objects such as database connections or Tensorflow
            sessions, use `st.cache_resource` instead (see [our docs](https://docs.streamlit.io/library/advanced-features/caching) for differences).
2024-02-27 16:25:55.104 Uncaught app exception
Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 698, in write_result
    pickled_entry = pickle.dumps(multi_cache_results)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle memoryview objects

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 330, in _handle_cache_miss
    cache.write_result(value_key, computed_value, messages)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 397, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 700, in write_result
    raise CacheError(f"Failed to pickle {key}") from exc
streamlit.runtime.caching.cache_errors.CacheError: Failed to pickle d279208d9cd381546cfd8d85c1b9c7c2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/main.py", line 8, in <module>
    df = conn.query('SELECT * FROM public.restaurant')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/connections/sql_connection.py", line 238, in query
    return _query(
           ^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
    return cached_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
    return self._get_or_create_cached_value(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 268, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 346, in _handle_cache_miss
    raise UnserializableReturnValueError(
streamlit.runtime.caching.cache_errors.UnserializableReturnValueError: 
            Cannot serialize the return value (of type `pandas.core.frame.DataFrame`) in `_query()`.
            `st.cache_data` uses [pickle](https://docs.python.org/3/library/pickle.html) to
            serialize the function’s return value and safely store it in the cache without mutating the original object. Please convert the return value to a pickle-serializable type.
            If you want to cache unserializable objects such as database connections or Tensorflow
            sessions, use `st.cache_resource` instead (see [our docs](https://docs.streamlit.io/library/advanced-features/caching) for differences).
2024-02-27 16:25:55.461 Uncaught app exception
Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 698, in write_result
    pickled_entry = pickle.dumps(multi_cache_results)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle memoryview objects

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 330, in _handle_cache_miss
    cache.write_result(value_key, computed_value, messages)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 397, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_data_api.py", line 700, in write_result
    raise CacheError(f"Failed to pickle {key}") from exc
streamlit.runtime.caching.cache_errors.CacheError: Failed to pickle d279208d9cd381546cfd8d85c1b9c7c2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/main.py", line 8, in <module>
    df = conn.query('SELECT * FROM public.restaurant')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/connections/sql_connection.py", line 238, in query
    return _query(
           ^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
    return cached_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
    return self._get_or_create_cached_value(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 268, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brocklunardi/PycharmProjects/streamlittdemo/venv/lib/python3.12/site-packages/streamlit/runtime/caching/cache_utils.py", line 346, in _handle_cache_miss
    raise UnserializableReturnValueError(
streamlit.runtime.caching.cache_errors.UnserializableReturnValueError: 
            Cannot serialize the return value (of type `pandas.core.frame.DataFrame`) in `_query()`.
            `st.cache_data` uses [pickle](https://docs.python.org/3/library/pickle.html) to
            serialize the function’s return value and safely store it in the cache without mutating the original object. Please convert the return value to a pickle-serializable type.
            If you want to cache unserializable objects such as database connections or Tensorflow
            sessions, use `st.cache_resource` instead (see [our docs](https://docs.streamlit.io/library/advanced-features/caching) for differences).



Closing as duplicate of Reading from Postgres DB gives serialization error