rmysql

Handling field types in database interaction with R

风流意气都作罢 提交于 2019-11-29 01:36:15
问题 I use RMySQL and a MySQL database to store my datasets. Sometimes data gets revised or I store results back to the database as well. Long story short, there is quite some interaction between R and the database in my use case. Most of the time I use convenience functions like dbWriteTable and dbReadTable to write and read my data. Unfortunately these are just completely ignoring R data types and the MySQL field types. I mean I would expect that MySQL date fields end up in a Date or POSIX class

Connect to MySQL database with RMySQL

别来无恙 提交于 2019-11-29 01:25:49
问题 I am making the move from RSQLite to RMySQL and I am confused by the user and password fields. FWIW, I'm running Windows 7, R 2.12.2, MySQL 5.5 (all 64 bit), and RMySQL 0.7-5. I installed RMySQL as prescribed in this previous SO question, and as far as I know it works (i.e., I can load the package with library(RMySQL) ). But when I try to run the tutorial from the R data import guide, I get a "failed to connect to database..." error. This is the code from the tutorial from the guide: library

How to Connect R with MySQL or how to install RMySQL package?

懵懂的女人 提交于 2019-11-28 21:56:31
I am new in R and i am trying to connect R with MySQL. I have installed mysql-5.5.22-winx64 and R-2.12.0 for 64 bit. I have already set MYSQL_HOME environment path(C:\Program Files\MySQL\MySQL Server 5.5) and trying to follow these steps: Install latest RTools from here install MySQL or header and library files of mysql create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line like MYSQL_HOME=C:/mysql (path to your mysql files) copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies. copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32

Add a dynamic value into RMySQL getQuery [duplicate]

北慕城南 提交于 2019-11-28 01:18:56
This question already has an answer here: Dynamic “string” in R 2 answers Is it possible to pass a value into the query in dbGetQuery from the RMySQL package. For example, if I have a set of values in a character vector: df <- c('a','b','c') And I want to loop through the values to pull out a specific value from a database for each. library(RMySQL) res <- dbGetQuery(con, "SELECT max(ID) FROM table WHERE columna='df[2]'") When I try to add the reference to the value I get an error. Wondering if it is possible to add a value from an R object in the query. One option is to manipulate the SQL

Can't connect to local MySQL server through socket error when using SSH tunel

故事扮演 提交于 2019-11-27 16:13:20
问题 I am trying to use dplyr to connect to a remote database, that I usually query through a ssh tunnel. I first set up a ssh tunnel like the following: alias tunnel_ncg='ssh -fNg -L 3307:127.0.0.1:3306 mysqluser@myhost mysql5 -h 127.0.0.1:3306 -P 3307 -u mysqluser -p mypassword' At this point I can access the database by connecting to localhost:3307. For example: mysql -h '127.0.0.1' -P 3307 -u mysqluser If I try to access the same database through dplyr, I get an error complaining that it can't

How to Connect R with MySQL or how to install RMySQL package?

守給你的承諾、 提交于 2019-11-27 14:06:44
问题 I am new in R and i am trying to connect R with MySQL. I have installed mysql-5.5.22-winx64 and R-2.12.0 for 64 bit. I have already set MYSQL_HOME environment path(C:\Program Files\MySQL\MySQL Server 5.5) and trying to follow these steps: Install latest RTools from here install MySQL or header and library files of mysql create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line like MYSQL_HOME=C:/mysql (path to your mysql files) copy libmysql.lib from mysql/lib to mysql

adding RMySQL package to R fails (on Windows)?

一笑奈何 提交于 2019-11-27 04:17:39
I can't figure out why my RMySQL package won't install - here's what I get: > install.packages('RMySQL',type='source') trying URL 'http://cran.mirrors.hoobly.com/src/contrib/RMySQL_0.7-5.tar.gz' Content type 'application/x-gzip' length 160769 bytes (157 Kb) opened URL downloaded 157 Kb * installing *source* package 'RMySQL' ... ERROR: configuration failed for package 'RMySQL' * removing 'C:/PROGRA~1/R/R-212~1.0/library/RMySQL' The downloaded packages are in '(foo)' Warning message: In install.packages("RMySQL", type = "source") : installation of package 'RMySQL' had non-zero exit status I don

Add a dynamic value into RMySQL getQuery [duplicate]

巧了我就是萌 提交于 2019-11-26 23:30:56
问题 This question already has an answer here: Dynamic “string” in R 3 answers Is it possible to pass a value into the query in dbGetQuery from the RMySQL package. For example, if I have a set of values in a character vector: df <- c('a','b','c') And I want to loop through the values to pull out a specific value from a database for each. library(RMySQL) res <- dbGetQuery(con, "SELECT max(ID) FROM table WHERE columna='df[2]'") When I try to add the reference to the value I get an error. Wondering

RMySQL dbWriteTable with field.types

拜拜、爱过 提交于 2019-11-26 13:58:20
问题 I have a data frame, called df , that looks like this: dte, val 2012-01-01, 23.2323 2012-01-02, 34.343 The type on the columns is date and numeric. I would like to write this to a MySQL database using an already open connection. The connection works fine as I am able to query the db fine. I try to run the following: dbWriteTable(con, name="table_name", value=df, field.types=list("date", "double(20,10)")) This generates the error: Error in function (classes, fdef, mtable) : unable to find an

adding RMySQL package to R fails (on Windows)?

痴心易碎 提交于 2019-11-26 11:07:48
问题 I can\'t figure out why my RMySQL package won\'t install - here\'s what I get: > install.packages(\'RMySQL\',type=\'source\') trying URL \'http://cran.mirrors.hoobly.com/src/contrib/RMySQL_0.7-5.tar.gz\' Content type \'application/x-gzip\' length 160769 bytes (157 Kb) opened URL downloaded 157 Kb * installing *source* package \'RMySQL\' ... ERROR: configuration failed for package \'RMySQL\' * removing \'C:/PROGRA~1/R/R-212~1.0/library/RMySQL\' The downloaded packages are in \'(foo)\' Warning