-
How do i avoid such connection issue. What soultion i have other than restarting my flask app ? Error After few minutes, i get above error. Connection gets lost. |
Beta Was this translation helpful? Give feedback.
Answered by
assinchu
Mar 1, 2024
Replies: 1 comment 3 replies
-
@assinchu could you show the code that you're using to connect to MySQL (please exclude the password and other private information) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If someone is having similar issue: They can use below snippet to re connect to MySQL when there is disconnect
vn = MyVanna(config={'api_key': '', 'model': 'gpt-3.5-turbo'})
conn_details = {
'user': '',
'password': '',
'host': '',
'database': ''
}
import mysql.connector
def connect_to_mysql(conn_details):
try:
# Establish a connection
conn = mysql.connector.connect(**conn_details)
if conn.is_connected():
print('Connected to MySQL database!')
# Print the connection details
print('Connection details:', conn_details)
return conn
except mysql.connector.Error as e:
print(f'Error connecting to MySQL database: {e}')
return None
Connect to MySQL
connection = connect_to_mysql(conn_details)
You def…