python+MySQLdb を用いた次のようなinsert処理で
_mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away')
とコネクションタイムアウトが発生しています。
この回避方法についてアドバイスをいただけないでしょうか?
import MySQLdb connector = MySQLdb.connect( host="localhost", hogehoge ) connector.ping(True) all_user_cursor = connector.cursor() #ユーザーリストを作成 all_user_cursor.execute( "select id from users" ) for user in all_user_cursor.fetchall(): cursor = connector.cursor() << 1分ぐらいの長めの処理 >> cursor.execute( "insert into data ( user_id, hogehoge ) values ( %s, %s )", ( [uid], hogehoge ) ) connector.commit()
途中の処理時間が短い頃は、問題なく処理が行えていました。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。