I usually work with flat files but this time I'm trying to connect to a relational database but with no success. First time for me, I therefore apologize in advance if the question is silly.
Here are the details of the ODBC connection enter image description here
And here is the code I am using to try to connect
install.packages("RMySQL")
library(DBI)
dbConnect(RmySQL::MySQL(),dbname="nicer_med", host="WRGTNICER1", port=3306, user="root", password="xxxxx")
and the error message I get
> dbConnect(RmySQL::MySQL(),dbname="nicer_med", host="WRGTNICER1", port=3306, user="root", password="Rgt_9098")
Error in (function (cond) :
erreur d'�valuation de l'argument 'drv' lors de la s�lection d'une m�thode pour la fonction 'dbConnect' : aucun package nommé ‘RmySQL’ n'est trouvé
I have tried another strategy using another package
install.packages("RODBC")
library(RODBC)
mycon<-odbcConnect("nicer_64")
Here the connection seems to work as I am able to describe the tables:
sqlTables(mycon)
sqlColumns(mycon,"a_patient")
Both are working but my queries actually don't:
> sqlQuery(mycon,paste("SELECT PID,NAME, FIRSTNAME1, SEXE, FROM a_patient;"))
[1] "42000 1064 [MySQL][ODBC 5.1 Driver][mysqld-5.6.22-log]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM a_patient' at line 1"
[2] "[RODBC] ERROR: Could not SQLExecDirect 'SELECT PID,NAME, FIRSTNAME1, SEXE, FROM a_patient;'"
I have tried several Sql dialects : uppercase, lowercase, with or without ";" and """, nothing is working for me.
I am still trying to find a way to have access to the data...I would be very happy to find some help. Thanks.