rodbc

R: Painfully slow read performance using RODBC & SQL Server

雨燕双飞 提交于 2019-12-03 04:22:35
问题 I am new to R but am interested in using Shiny to create dynamic charts using data stored in a SQL Server database. To enable interactivity, I want to bring in the raw data from the database and perform calculations within R rather than have the database summarize the data. I am able to connect to the database using RODBC , execute a query, and receive results in a data.frame . However, the read time in R is about 12x longer than than the same query executed in SQL Server Management Studio

R: Painfully slow read performance using RODBC & SQL Server

放肆的年华 提交于 2019-12-02 17:46:58
I am new to R but am interested in using Shiny to create dynamic charts using data stored in a SQL Server database. To enable interactivity, I want to bring in the raw data from the database and perform calculations within R rather than have the database summarize the data. I am able to connect to the database using RODBC , execute a query, and receive results in a data.frame . However, the read time in R is about 12x longer than than the same query executed in SQL Server Management Studio (SSMS). SSMS takes ~600 ms, whereas R takes about 7.6 seconds. My question is whether I am doing

RODBC query falsely returning zero rows

∥☆過路亽.° 提交于 2019-12-02 11:45:48
I have come across similar posts, but my issue looks different. I haven't been able to fix the results to these queries with "rows_at_time=1" or "believeNRows = False". I am trying to connect to an Oracle database using RODBC within R. I am able to connect to the database, but I am not retrieving any data, except the column headings. For example I will have zero observations on 18 variables from one table. I do this at work on my PC all the time, but am trying to do this on my macbook pro at home. Below is the connection code db<-odbcConnect(dsn="DW", uid="XXXXXX", pwd="XXXXX", rows_at_time =

Pasting Values in SQL Query through R

为君一笑 提交于 2019-12-02 03:36:49
问题 I have the following dataframe which contains the AxiomaID. x<-c(0123, 234, 2348, 345, 3454) And trying to run the following SQL Query within R. SQL6<-data.frame(sqlQuery(myConn, "SELECT top 10 [AxiomaDate] ,[RiskModelID] ,[AxiomaID] ,[Factor1] FROM [PortfolioAnalytics].[Data_Axioma].[SecurityExposures] Where AxiomaID = x")) How can I paste all the x values which contain the AxiomaID's into the SQL Query? 回答1: Try the following query: SQL6<-data.frame(sqlQuery(myConn, paste("SELECT top 10

Pasting Values in SQL Query through R

耗尽温柔 提交于 2019-12-02 00:39:23
I have the following dataframe which contains the AxiomaID. x<-c(0123, 234, 2348, 345, 3454) And trying to run the following SQL Query within R. SQL6<-data.frame(sqlQuery(myConn, "SELECT top 10 [AxiomaDate] ,[RiskModelID] ,[AxiomaID] ,[Factor1] FROM [PortfolioAnalytics].[Data_Axioma].[SecurityExposures] Where AxiomaID = x")) How can I paste all the x values which contain the AxiomaID's into the SQL Query? Try the following query: SQL6<-data.frame(sqlQuery(myConn, paste("SELECT top 10 [AxiomaDate] ,[RiskModelID] ,[AxiomaID] ,[Factor1] FROM [PortfolioAnalytics].[Data_Axioma].[SecurityExposures]

RODBC: merge tables from different databases (channel)

做~自己de王妃 提交于 2019-12-01 18:08:40
I'm using RODBC package to connect to Oracle databases from R but I didn't succeed in merging tables from different databases without "downloading" the tables (I don't want to download them as they are too big!). I'd like to use something like: DBa=odbcConnect(dsn="DatabaseA",uid="uid",pwd="pwd",readOnly="True") DBb=odbcConnect(dsn="DatabaseB",uid="uid",pwd="pwd",readOnly="True") sqldf("select a.year, sum(b.var) as sumVar from sqlFetch(DBa,'tableA') a sqlFetch(DBb,'tableB') b where a.ID=b.ID group by a.year") If someone has an idea, it would be really helpful! Many thanks in advance. Lionel

How to specify include and lib directories when locally installing RODBC?

我只是一个虾纸丫 提交于 2019-12-01 12:51:38
问题 i am trying to install RODBC with the commadn R CMD INSTALL -l /my/local/path RODBC.tar.gz and it wont find sql.h and sqlext.h ..how do i pass the include and lib paths to this command? 回答1: I had a similar problem recently while trying to install RODBC on an instance of Centos 5.8 x64. (Instead of using R CMD install, I just did sudo R, then installed the package inside R - but I was still having the same problem). I resolved this by installing the following packages using yum : unixODBC

How to insert data to SQL Server table using R?

北慕城南 提交于 2019-12-01 10:57:34
I need help to write a simple data row to SQL server from R Language. (using RODBC or otherwise). You can write all the data (all rows) using sqlSave(channel, data, rownames = FALSE) where channel <- odbcDriverConnect("Driver={SQL Server};Server=AAA;Uid=BBB;Pwd=CCC;") . This will create a table with a name data in your database. You can then append your existing table by sqlQuery(channel, 'insert into table select * from data') . 来源: https://stackoverflow.com/questions/34591444/how-to-insert-data-to-sql-server-table-using-r

How to insert data to SQL Server table using R?

时光毁灭记忆、已成空白 提交于 2019-12-01 08:25:52
问题 I need help to write a simple data row to SQL server from R Language. (using RODBC or otherwise). 回答1: You can write all the data (all rows) using sqlSave(channel, data, rownames = FALSE) where channel <- odbcDriverConnect("Driver={SQL Server};Server=AAA;Uid=BBB;Pwd=CCC;") . This will create a table with a name data in your database. You can then append your existing table by sqlQuery(channel, 'insert into table select * from data') . 来源: https://stackoverflow.com/questions/34591444/how-to

RODBC using Data.Frame in a Join on sqlQuery()

旧时模样 提交于 2019-12-01 06:30:55
问题 Is there a way to use a data.frame in JOIN condition using sqlQuery()? I'm connecting to SQL server using RODBC and need to limit the inital result set against a data.frame I've already got in R so it only returns 4000 records out of 200,000. Something like.... My_Data<- as.data.frame(c(1,2,3,4,5,6,7,8)) my_Query<- paste("SELECT * FROM foo INNER JOIN ",My_Data,"ON foo.x = My_Data.x", sep="") my_Answer<- sqlQuery(Connection, my_Query) I can do it by pulling the entire table into R and then