rodbc

Special characters and RODBC

大兔子大兔子 提交于 2019-12-11 02:57:28
问题 in a database I have strings stored that contain special characters such as "§". Using the command sqlQuery() from package RODBC "§" is translated to "?". This is also the case for characters such as " ' " as it can be found in French words. Of course I can not replace every "?" by one of the special characters after the query. Does anybody have an idea for this problem? I work under windows 7. As requested the out put of sessionInfo() R version 2.14.1 (2011-12-22) Platform: x86_64-pc-mingw32

Providing lookup list from R vector as SQL table for RODBC lookup

和自甴很熟 提交于 2019-12-10 22:18:34
问题 I have a list of IDs in an R vector. IDlist <- c(23, 232, 434, 35445) I would like to write an RODBC sqlQuery with a clause stating something like WHERE idname IN IDlist Do I have to read the whole table and then merge it to the idList vector within R? Or how can I provide these values to the RODBC statement, so recover only the records I'm interested in? Note: As the list is quite long, pasting individual values into the SQL statement, as in the answer below, won't do it. 回答1: You could

sqlSave in R to create and save a dataframe to an sql table

[亡魂溺海] 提交于 2019-12-10 18:32:15
问题 Hi I am using R to save a data frame into a DB2 SQL table. I seem to be able to create the table skeleton, but not append the data to the table - >df <- read.csv("dat.csv") where dat.csv is a csv with no headers, just raw data in two columns then i create the table: >sqlQuery(channel, "create table sqltable ( col1 int, col2 float )" ( where I confirm the table is created by being able to select the empty table "sqltable" on the database so now I need to add the data from "dat.csv" into

Querying Oracle DB from Revolution R using RODBC

血红的双手。 提交于 2019-12-10 13:13:33
问题 RODBC error in Revolution R 64bit on winxp64 bit connected to Oracle using a 64bit ODBC driver thru a DSN library(RODBC) db <- odbcConnect("oraclemiso",uid="epicedf",pwd="…") rslts = sqlQuery(db, "select count(*) from FTRAuction") Error in .Call(C_RODBCFetchRows, attr(channel, "handle_ptr"), max, buffsize, : negative length vectors are not allowed I am able to connect but get an error when I query for stuff, also the below works library(RODBC) channel <- odbcConnect("OraLSH", <user>,

connect R to MySQL with RODBC using dsn

最后都变了- 提交于 2019-12-10 10:03:59
问题 Short version: I'm trying to figure out how to use the dsn argument in the odbcConnect() function to connect to a MySQL database. Longer version: I appologize if this is an ignorant question. I didn't find an answer on SO searching under the tags. I'm not new to R, although I'm not the world's foremost expert. I am new to MySQL. I have been trying to learn it on my own. I would like to be able to create tables and such in R and write them to a database in MySQL and then be able to select from

How do I connect to an SQL server database in R

白昼怎懂夜的黑 提交于 2019-12-10 09:23:46
问题 I'm trying to connect to the SQL Sever database using R but not sure on the details for the query string. I normally use SQL server management studio on SQL Server 2008 and connnect using single sign on. I found the below example myconn <- odbcDriverConnect(connection="Driver={SQL Server Native Client 11.0};server=hostname;database=TPCH; trusted_connection=yes;") I get the below warning message Warning messages: 1: In odbcDriverConnect(connection = "Driver={SQL Server \nNative Client 11.0}

odbcConnectExcel function from RODBC package for R not found on Ubuntu

不羁岁月 提交于 2019-12-10 04:04:54
问题 Installing the RODBC package on Ubuntu is a bit of a kludge. First I learned to install the following: $ sudo apt-get install r-cran-rodbc That wasn't good enough as the package was still looking for header files. I solved this issue by: $ sudo apt-get install unixodbc-dev Good, RODBC installed properly on the Ubuntu machine. But when I try to run the following script: ## import excel file from Dropbox require("RODBC") channel <- odbcConnectExcel("~/Dropbox/DATA/SAMPLE/petro.xls") petro <-

Problems with RODBC sqlSave

被刻印的时光 ゝ 提交于 2019-12-09 10:44:58
问题 I'm having some difficulty inserting a data frame into a mySql database using RODBC. Below is the code I'm using: data <- data.frame(analysedDataID=c(1,2,3), plateWell=c("a","b","c"), screenPlateOrder=c(1,2,3), wellData=c("A","B","C")) con <- odbcConnect(DSN, uid="user_id", pwd="some_password") query <- sqlSave(con, data, tablename = 'wellAnalysedDataTable', rownames=FALSE, append=TRUE) When I try to execute this I get the following error message: Error in odbcUpdate(channel, query, mydata,

annoying “feature” (or bugs?) for RODBC

依然范特西╮ 提交于 2019-12-09 00:34:38
问题 RODBC is the main library in R to import data from a database into R. RODBC seems to have the ability of "guess" the datatype of the column which I find it particularly annoying. I have uploaded a file test.xls here, or you may create a xls file yourself: create 2 columns, first column named col_a and the second column named col_b . type whatever you like in col_a , I typed letters on this column for 92 rows at the 92th row of col_b, type a number there, I typed "1923" without changing the

Why won't RODBC upload a dataframe to SQL Server?

余生长醉 提交于 2019-12-08 21:04:15
问题 library(RODBC) con <- odbcDriverConnect("driver=SQL Server; server=name") df <- data.frame(a=1:10, b=10:1, c=11:20) Trying to upload the dataframe: sqlSave(con, df, tablename='[MyDatabase].[MySchema].[MyTable]', rownames=F) >Error in sqlColumns(channel, tablename) : ‘MyDatabase.MySchema.MyTable’: table not found on channel ..alternatively creating the table first and then appending to it: cmd <- "create table [MyDatabase].[MySchema].[MyTable] ([a] int, [b] int, [c] int)" sqlQuery(con, cmd)