Questions tagged [rmysql]

An R package for interfacing with MySQL and MariaDB databases.

RMySQL is an package providing an interface to and databases. RMySQL uses the interface which is also used by the packages , , , and .

Repositories

Other resources

Related tags

418 questions
4
votes
0 answers

"set" statement RMySQL and DBI package

I am using 'RMySQL' and 'DBI' for MySQL database connection. Does anyone know if it is possible to use the set @variable := something when sending queries with DBI::dbGetQuery function? When trying to pass the query, I am getting an error that…
4
votes
2 answers

Connection lost when connect R to MySQL using collect

I would like to use dplyr and RMySQL to work with my large data. There is no issues with dplyr code. The problem (I think) is about exporting data out of MySQL to R. My connection is dropped every time even I am using n=Inf in collect.…
TTT
  • 4,354
  • 13
  • 73
  • 123
4
votes
1 answer

importing date correctly from MySQL into R

My question is pretty much the same as this one. In short, I'm using dplyr (along with RMySQL) to import a MySQL table with a datetime column, and I want to convert it to date in R. In the question linked above, no answer was posted, only a comment…
Manoel Galdino
  • 2,376
  • 6
  • 27
  • 40
4
votes
0 answers

Connect to sql server database on linux with R

I'm trying to connect to a microsoft sql database through R on a VM with ubuntu 16.04 as the OS. I have installed DBI, RMySQL, RODBC and odbc packages. I can connect to an oracle database. Here is the command i tried using: con <-…
tonyk
  • 348
  • 5
  • 22
4
votes
2 answers

Unknown column in field list error Rmysql

I wrote a data.frame using dbWriteTable(con, name='db_all', df, overwrite=T, row.names=F) sucessfully to MySQL using RMySQL. Now I have a second data frame which has a similar structure and try to use…
Luke
  • 43
  • 1
  • 4
4
votes
1 answer

Connect to MySQL database via dplyr using stored credentials

I would like to access a MySQL database using dplyr without having to store my database passwords in plane text R code. Hence, I'd prefer to reference my .my.cnf file, but since the src_mysql has default parameters for host, user, and password, the…
Jthorpe
  • 9,756
  • 2
  • 49
  • 64
4
votes
2 answers

Add column into existing mysql table using RMySQL

I want to be able to add a column into an existing table with its corresponding type. This is how I tried it: library("RMySQL") # Connect to DB v_db <- dbConnect(MySQL(), user="USERNAME", password="PASSWORD", …
Thomas
  • 1,392
  • 3
  • 22
  • 38
4
votes
1 answer

RMySQL dbGetQuery() inside function leaves pending results

My function, contained in a larger function, uses dbConnect(), dbGetQuery(), and dbDisconnect(). When the function errors out, I fix it and try to rerun it. I can't rerun it though, because I get: Error in mysqlCloseConnection(conn, ...) : …
StatSandwich
  • 1,134
  • 11
  • 14
4
votes
0 answers

connection error when executing multiple queries on RMySQL

I m running the following code block 8 times, but with different queries in three different R scripts. I have already established the connection with the server. rs<-dbSendQuery(con,"select owner_name, owner_domain, count(*) as avg from…
m_amber
  • 747
  • 3
  • 13
  • 23
3
votes
1 answer

Is there any options to define specific time limit to dbGetQuery

This for R, DBI package. Is there any options or parameters to limit the SQL query time. couldn't find any options from dbConnect(drv, ...) dbGetQuery(conn, statement, ...) pool package provides idleTimeout options, but couldn't find options or…
Kg211
  • 132
  • 1
  • 7
3
votes
3 answers

Insert into MySQL from R

I am using DBI package to insert data to MySQL. Here is the code: ch <- DBI::dbConnect(MySQL()) dbSendQuery(ch, 'set character set "utf8"') dbSendQuery(ch, 'SET NAMES utf8') for (i in 1:nrow(test)) { query <- paste0("INSERT INTO trade_data…
Mislav
  • 1,533
  • 16
  • 37
3
votes
2 answers

source()ing a file changes the BOM characters in a function

I have a .R file that contains several functions, one of which is defined as: get_entry_detail <- function(con, vec_of_entryids){ query <- paste0("select entryId, fieldName, fieldValue from…
Steven
  • 3,238
  • 21
  • 50
3
votes
0 answers

error dbWriteTable Unknown column '$1' in 'field list'

Had a Rscript for inserting a dataframe into MariaDB working ok. Nobody changed anything but suddenly started to fail. insertconnection <- dbConnect(RMariaDB::MariaDB(), user = 'user', password = 'pwd', dbname =…
Forge
  • 1,587
  • 1
  • 15
  • 36
3
votes
0 answers

Using placeholders in RMySQL queries

I am trying to use placeholders with my RMySQL queries. For example, I have this table in MySQL, id name birth color foods cats 1 Sybil 1970-04-13 black lutefisk,fadge,pizza 3 2 Nancy …
jochapjo
  • 33
  • 4
3
votes
1 answer

SSH within R script to get to MySQL Database

I am trying to connect to a MySQL server, which is restricted by being connected to a given server. I am trying to connect through this restricting server while not physically connected. Through the command line this is doable by creating a SSH…
kneijenhuijs
  • 1,189
  • 1
  • 12
  • 21