rodbc

Parameterized queries with RODBC

安稳与你 提交于 2019-11-26 22:54:15
I have a variable in R that I would like to pass to a database. I could use paste like many suggest when reading Google results, but that is unsafe because of SQL injection vulnerabilities. I'd rather prefer something like this: x <- 42 sqlQuery(db, 'SELECT Id, Name FROM People WHERE Age > ?;', bind=c(x)) Is it possible to use parameterized queries with RODBC? If not, is there an alternative library that supports them? I'm using SQL Server, RODBC 1.3-6 and R 3.0.0. Mateusz Zoltak wrote RODBCext package in 2014 (based on work by Brian Ripley and Michael Lapsley): conn = odbcConnect(

RODBC odbcDriverConnect() Connection Error

佐手、 提交于 2019-11-26 20:21:29
I'm trying to use odbcDriverConnect('driver={SQL Server};server=servername\instancename,port;database=testing;username=abc;password=123456') to connect remote database server (sql server 2008). But I got [RODBC] ERROR: state 08001, code 17, message [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. error. Any idea? I can use odbcDriverConnect('driver={SQL Server};server=localhost;database=testing;trusted_connection=true') to connect my local database server (sql server 2008). lijie98 The correct syntax should be: odbcDriverConnect('driver={SQL Server}

RODBC queries returning zero rows

拥有回忆 提交于 2019-11-26 19:59:27
问题 Issue: RODBC (falsely) returning zero rows Situation: I'm using RODBC to connect to a DSN I created using a commercial DB's ODBC driver (OSI Soft's PI Historian Time Series DB, if you're curious). > library(RODBC) > piconn <- odbcConnect("PIRV", uid = "pidemo") > sqlStr <- "SELECT tag, time, status, value FROM piinterp WHERE tag = 'PW1.PLANT1.PRODUCTION_RATE' and time > DATE('-4h') and timestep = '+2m'" Now if I query, I get zero rows. > sqlQuery(piconn, sqlStr) [1] TAG TIME STATUS VALUE <0

Pass R variable to RODBC's sqlQuery? [duplicate]

廉价感情. 提交于 2019-11-26 17:36:30
This question already has an answer here: Dynamic “string” in R 2 answers Add a dynamic value into RMySQL getQuery [duplicate] 2 answers RSQLite query with user specified variable in the WHERE field [duplicate] 2 answers Is there any way to pass a variable defined within R to the sqlQuery function within the RODBC package? Specifically, I need to pass such a variable to either a scalar/table-valued function, a stored procedure, and/or perhaps the WHERE clause of a SELECT statement. For example, let: x <- 1 ## user-defined Then, example <- sqlQuery(myDB,"SELECT * FROM dbo.my_table_fn (x)") Or..

Failure to connect to odbc database in R

痴心易碎 提交于 2019-11-26 17:10:44
问题 I've been trying to connect my company's DMS to R using the odbcConnect command, but get the following message: myConn <-odbcConnect("NZSQL", uid="cejacobson", pwd="password") Warning messages: 1: In odbcDriverConnect("DSN=NZSQL;UID=cejacobson;PWD=password") : [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data source name not found, and no default driver specified 2: In odbcDriverConnect("DSN=NZSQL;UID=cejacobson;PWD=password") : ODBC connection failed The thing is, I

RODBC Temporary Table Issue when connecting to MS SQL Server

こ雲淡風輕ζ 提交于 2019-11-26 16:25:17
问题 I am running R on unix and I am using the RODBC package to connect to MS SQL server. I can execute a query that returns results fine with the package, but if I use a temporary table somewhere in my SQL query, an empty string is returned to me. After looking over the web, I think the problem might be that the RODBC package was written assuming an end-user was writing in standard SQL (as opposed to MS SQL). I have provided the below code as an example. Interestingly enough, the temporary table

Installation of RODBC/ROracle packages on OS X Mavericks

巧了我就是萌 提交于 2019-11-26 16:22:47
I have been trying to install some packages such as RODBC, ROracle or RGtk2 - used for rattle. I would really appreciate it if someone could help me get around this problem so that I could use these applications on a Mac with mavericks and with 3.1.1 R I get this sort of error for both RODBC and RGtk2: package ‘RGtk2’ is available as a source package but not as a binary Warning in install.packages : package ‘RGtk2’ is not available (for R version 3.1.1) When I try to use type='source', I can download or start to download but then I get this sort of error message... Warning in install.packages

RODBC odbcDriverConnect() Connection Error

不打扰是莪最后的温柔 提交于 2019-11-26 09:00:56
问题 I\'m trying to use odbcDriverConnect(\'driver={SQL Server};server=servername\\instancename,port;database=testing;username=abc;password=123456\') to connect remote database server (sql server 2008). But I got [RODBC] ERROR: state 08001, code 17, message [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. error. Any idea? I can use odbcDriverConnect(\'driver={SQL Server};server=localhost;database=testing;trusted_connection=true\') to connect my local

Parameterized queries with RODBC

拜拜、爱过 提交于 2019-11-26 08:28:01
问题 I have a variable in R that I would like to pass to a database. I could use paste like many suggest when reading Google results, but that is unsafe because of SQL injection vulnerabilities. I\'d rather prefer something like this: x <- 42 sqlQuery(db, \'SELECT Id, Name FROM People WHERE Age > ?;\', bind=c(x)) Is it possible to use parameterized queries with RODBC? If not, is there an alternative library that supports them? I\'m using SQL Server, RODBC 1.3-6 and R 3.0.0. 回答1: Mateusz Zoltak

How to connect R with Access database in 64-bit Window?

◇◆丶佛笑我妖孽 提交于 2019-11-26 06:30:25
问题 When I tried to connect R with Access database I get an error odbcConnectAccess is only usable with 32-bit Windows Does anyone has an idea how to solve this? library(RODBC) mdbConnect<-odbcConnectAccess(\"D:/SampleDB1/sampleDB1.mdb\") 回答1: Use odbcDriverConnect instead. If you have 64-bit R installed, you may have to use the 32-bit R build. odbcDriverConnect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D:/SampleDB1/sampleDB1.mdb") 回答2: Here is a single function that will transfer