Answer the question
In order to leave comments, you need to log in
How to solve pyMySQL connection problem?
import pymysql
class Users:
def __init__(self):
self.conn = pymysql.connect('localhost', 'admin', 'pass', 'myDB')
self.cursor = self.conn.cursor()
def insert(self, user_id, username):
with self.conn:
self.cursor.execute('INSERT INTO users(user_id, username) '
'VALUES (%s,%s)', (user_id, username))
self.conn.commit()
CR.CR_SERVER_LOST, "Lost connection to MySQL server during query")
pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question