0

Need help in inserting data into MySQL using R. I am getting the following error and do not know how to fix this:

Error: C stack usage  7971984 is too close to the limit

This is not a memory allocation problem, as I have tried inserting a much smaller dataset, but still i get this error. Also whenever i run dbWriteTable() function it deletes the table i have created in MySQL DB.

The table i have created in MySQL for insertion is:

+------------+--------------+------+-----+---------+-------+
| Field      | Type         | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| concat     | varchar(26)  | YES  | UNI | NULL    |       |
| store_id   | varchar(26)  | NO   |     | NULL    |       |
| product_id | varchar(26)  | NO   |     | NULL    |       |
| predicted  | decimal(3,1) | NO   |     | NULL    |       |
+------------+--------------+------+-----+---------+-------+

The table in R for insertion is:

'data.frame':   28709 obs. of  4 variables:
 $ unique    : chr  "204227_294" "204363_294" "92662_1471" "166876_1471" ...
 $ product_id: chr  "294" "294" "1471" "1471" "1495" "1504" "1508" "1508" "1508" "1508" ...
 $ store_id  : chr  "204227" "204363" "92662" "166876" ...
 $ predicted : num  0.204 0.697 0.204 0.827 0.204 ...

The code for inserting data into MySQL DB is:

mydb = dbConnect(RMySQL::MySQL(), username="XXXXXX", 
                                  password="YYYYY", 
                                  dbname='ZZZZZ',
                                  host="XX.Y.ZZ.XXXX", 
                                  port=3306)

dbWriteTable(mydb, name="analytics.fulfillment_ratio", 
                   value=final_combo, 
                   field.types=list(concat="varchar(26)",
                                    store_id="varchar(26)", 
                                    product_id="varchar(26)", 
                                    predicted="decimal(3,1)"),
                   row.names=FALSE, 
                   overwrite = TRUE)

Any help will be great...thanks.

Arshad Islam
  • 107
  • 1
  • 1
  • 10
  • Possible duplicate of [Error: C stack usage is too close to the limit](http://stackoverflow.com/questions/14719349/error-c-stack-usage-is-too-close-to-the-limit) – Ahmad Abuhasna May 17 '16 at 14:36
  • Can you check the nature/class of product_id in your data.frame; is it a factor requiring as.character? There are no quotes around values in what you show. – Eric Lecoutre May 17 '16 at 18:42
  • @EricLecoutre i checked once, the class is fine. I am still getting the error. – Arshad Islam May 19 '16 at 03:04
  • Did you see http://stackoverflow.com/questions/14719349/error-c-stack-usage-is-too-close-to-the-limit? I saw elsewhere two other people who resinstalled (fresh) R to resolve the problem but I suspect you have something else happening. What happens if you try to commit only 10 first rows? The issue may be that you have a string containing a quotation mark so that a very long string is built – Eric Lecoutre May 19 '16 at 14:05

0 Answers0