Skip to content
Back to formatted view

Raw Message

Message-ID: <524AC402.205@gmail.com>
Date: 2013-10-01T12:45:54Z
From: Magnus Torfason
Subject: RMySQL "lost connection" during dbWriteTable()

When doing dbWriteTable() to write my (admittedly large) data.frame to a 
MySQL database I randomly get the following error:

 >     dbWriteTable(conn, "tablename", data)
Error in mysqlExecStatement(conn, statement, ...) :
   RS-DBI driver: (could not run statement: Lost connection to MySQL 
server during query)

Googling on MySQL in general suggests that this can be the result of 
sending too big of a chunk of data to MySQL at the same time.

But the data.frame sits comfortably in memory and the table sits 
comfortably in the database. So it is disappointing that what I thought 
was the recommended way to achieve this task (dbWriteTable), should be a 
bottleneck.

I suppose I could write a loop around dbWriteTable(), writing only a few 
rows of the data.frame at the same time, but that seems like something 
that dbWriteTable() should be doing internally.

Are there any good suggestions on what I should do?

Best,
Magnus