Hi, I am getting this error while running my app.
hash function via the hash_funcs
keyword in @st.cache(). For example:
xpecta_1 |
xpecta_1 | xpecta_1 | @st.cache(hash_funcs={_io.TextIOWrapper: my_hash_func}) xpecta_1 | def my_func(...): xpecta_1 | ... xpecta_1 |
xpecta_1 |
xpecta_1 | If you don’t know where the object of type _io.TextIOWrapper
is coming
xpecta_1 | from, try looking at the hash chain below for an object that you do recognize,
xpecta_1 | then pass that to hash_funcs
instead:
xpecta_1 |
xpecta_1 | ```
The function that is generating the error is this one:
@st.cache(ttl=28800)
def upload_data():
################################ CONNECTION TO MYSQL ################################
try:
db = mysql.connector.connect(host=os.getenv('DB_HOST'),database=os.getenv('DB_NAME'),user=os.getenv('DB_USER'),password=os.getenv('DB_PASSWORD'))
if db.is_connected():
db_Info = db.get_server_info()
logger.info(f"Connected to MySQL Server version {db_Info}")
df=pd.read_sql(query,db)
except Error as e:
logger.error(f"Error while connecting to MySQL: {str(e)}")
finally:
if db.is_connected():
db.close()
logger.info("MySQL connection is closed")
return df