Mysql connection error

Hi,

I have a trouble connecting streamlit to mysql db.

Iโ€™m testing my code locally.

import streamlit as st

# Initialize connection.
conn = st.connection('mysql', type='sql')

# Perform query.
df = conn.query('SELECT * from email_whitelists;', ttl=0)

# Print results.
for row in df.itertuples():
    print(f"{row}")

However, I get this error:

ValueError: invalid literal for int() with base 10: '5.7.42'
Traceback:
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
File "/Users/temp/Desktop/work/gksv2/phase1-mvp-demo/src/queries/connection.py", line 7, in <module>
    df = conn.query('SELECT * from email_whitelists;', ttl=0)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/streamlit/connections/sql_connection.py", line 238, in query
    return _query(
           ^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper
    return cached_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in __call__
    return self._get_or_create_cached_value(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/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/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/streamlit/runtime/caching/cache_utils.py", line 324, in _handle_cache_miss
    computed_value = self._info.func(*func_args, **func_kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/tenacity/__init__.py", line 289, in wrapped_f
    return self(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/tenacity/__init__.py", line 379, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/tenacity/__init__.py", line 314, in iter
    return fut.result()
           ^^^^^^^^^^^^
File "/Users/temp/anaconda3/lib/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
File "/Users/temp/anaconda3/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/tenacity/__init__.py", line 382, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/streamlit/connections/sql_connection.py", line 215, in _query
    instance = self._instance.connect()
               ^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3269, in connect
    return self._connection_cls(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 145, in __init__
    self._dbapi_connection = engine.raw_connection()
                             ^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3293, in raw_connection
    return self.pool.connect()
           ^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 452, in connect
    return _ConnectionFairy._checkout(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 1269, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 716, in checkout
    rec = pool._do_get()
          ^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/pool/impl.py", line 169, in _do_get
    with util.safe_reraise():
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/pool/impl.py", line 167, in _do_get
    return self._create_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 393, in _create_connection
    return _ConnectionRecord(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 678, in __init__
    self.__connect()
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 916, in __connect
    )._exec_w_sync_on_first_run(self.dbapi_connection, self)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/event/attr.py", line 485, in _exec_w_sync_on_first_run
    self(*args, **kw)
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/event/attr.py", line 499, in __call__
    fn(*args, **kw)
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 1917, in go
    return once_fn(*arg, **kw)
           ^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/engine/create.py", line 740, in first_connect
    dialect.initialize(c)
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/base.py", line 2829, in initialize
    default.DefaultDialect.initialize(self, connection)
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 514, in initialize
    self.server_version_info = self._get_server_version_info(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/base.py", line 2574, in _get_server_version_info
    cursor.execute("SELECT VERSION()")
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 332, in _query
    self._post_get_result()
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 366, in _post_get_result
    self._rows = self._fetch_row(0)
                 ^^^^^^^^^^^^^^^^^^
File "/Users/temp/Desktop/work/gksv2/gkenv/lib/python3.11/site-packages/MySQLdb/cursors.py", line 339, in _fetch_row
    return self._result.fetch_row(size, self._fetch_type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I have sqlalchemy and mysqlclient installed normallyโ€ฆ I really canโ€™t debug this problem.

Is 5.7.42 really an integer?

It is not a float, it must be a string.

I have no idea where that 5.7.42 came from so I cannot do anything even if 5.7.42 is float or string. Because of that iโ€™m not using st.connection anymore

Try to create a new database/table and access it.