r-dbi

Connect to MSSQL using DBI

末鹿安然 提交于 2019-12-22 05:18:22
问题 I can not connect to MSSQL using DBI package. I am trying the way shown in package itself m <- dbDriver("RODBC") # error Error: could not find function "RODBC" # open the connection using user, passsword, etc., as # specified in the file \file{\$HOME/.my.cnf} con <- dbConnect(m, dsn="data.source", uid="user", pwd="password")) Any help appreciated. Thanks 回答1: It looks like there used to be a RODBC driver for DBI, but not any more: http://cran.r-project.org/src/contrib/Archive/DBI.RODBC/ A bit

Print sql statement craeted by DBI::dbBind

烂漫一生 提交于 2019-12-20 03:33:11
问题 I want to print the sql syntax created with DBI::dbBind while creating safe parametrized query: conn <- #create connection stmt <- "select * from dbo.mytable where mycolumn = ?" params = list("myvalue") query <- DBI::dbSendQuery(conn, stmt) DBI::dbBind(query, params) # how print created sql syntax? in the last line the sql syntax is created. How to view it? 回答1: I'll formalize my comment into an answer. "Binding" does not change the query, it merely "augments" a query with objects that are

Missing letters of database objects being returned in DBI SQL Server ODBC connection

谁说胖子不能爱 提交于 2019-12-14 03:54:31
问题 Unfortunately, I will not be able to create a good repro for this issue without sharing confidential creds to the database I am having issues with. Hopefully I have enough information below to flag any obvious problems that ODBC experts will understand. Background I am running a MacBook Pro with the following specs: Model Name: MacBook Pro Model Identifier: MacBookPro15,1 Processor Name: 6-Core Intel Core i7 Processor Speed: 2.6 GHz Number of Processors: 1 Total Number of Cores: 6 L2 Cache

Connect to Teradata Database using R + DBI library + ODBC

五迷三道 提交于 2019-12-11 06:09:02
问题 I'm trying to connect to a Teradata Database in R using the DBI library (if it matters I'm on Windows). I can successfully connect using the RODBC library so I know my credentials etc. are correct. I suspect the issue is: I am not correctly specifying the authentication mechanism Wrong driver: instead of using ODBC, perhaps I should be using JDBC? Background: First here's my ODBC info if I look it the ODBC Database Source Administrator: Name = name_name Driver = Teradata Name or IP address =

SQL function not working when trying to write table to non-default schema

时光毁灭记忆、已成空白 提交于 2019-12-10 11:29:13
问题 I am trying to write a table to a non-default schema in SQL Server 2017. I am using RStudio's documentation as to what the best practice is for doing this: https://db.rstudio.com/best-practices/schema/#write-non-temporary-tables. However, when I follow their guidelines I get the following error: Error: Can't unquote EXISTING_SCHEMA.newTbleIris EDIT After some digging around, I have made some progress. But the issue isn't completely resolved. I have found the Id() function allows for me to

Loading SQLite table in R with RSQLite

允我心安 提交于 2019-12-10 10:51:02
问题 I had this function I used to load a SQLite table sqLiteConnect <- function(database, table) { library(DBI) library(RSQLite) con <- dbConnect("SQLite", dbname = database) query <- dbSendQuery(con, paste("SELECT * FROM ", table, ";", sep="")) result <- fetch(query, n = -1, encoding="utf-8") dbClearResult(query) dbDisconnect(con) return(result) } But now it seams it generates an error album <- sqLiteConnect("~/Downloads/ChinookDatabase1.3_Sqlite/Chinook_Sqlite.sqlite","Album") Error in

How to write binary data into SQLite with R DBI's dbWriteTable()?

≡放荡痞女 提交于 2019-12-10 10:16:57
问题 For instance, how to execute the equivalent following SQL (which inserts into a BINARY(16) field) INSERT INTO Table1 (MD5) VALUES (X'6717f2823d3202449201145073ab871A'),(X'6717f2823d3202449301145073ab371A') using dbWriteTable() ? Doing dbWriteTable(db, "Table1", data.frame(MD5 = "X'6717f2823d3202449201145073ab871A'", ...), append = T, row.names = F) doesn't seem to work - it writes the values as text. In the end, I'm going to have a big data.frame of hashes that I want to write, and so perfect

How to spread tbl_dbi and tbl_sql data without downloading to local memory

北城余情 提交于 2019-12-06 06:23:02
问题 I am working with large datasets and tidyr's spread usually gives me error messages suggesting failure to obtain memory to perform the operation. Therefore, I have been exploring dbplyr. However, as it says here, and also shown below, dbplyr::spread() does not work. My question here is whether there is another way to accomplish what tidyr::spread does while working with tbl_dbi and tbl_sql data without downloading to local memory. Using sample data from here, below I present what I get and

Loading SQLite table in R with RSQLite

半腔热情 提交于 2019-12-06 04:58:07
I had this function I used to load a SQLite table sqLiteConnect <- function(database, table) { library(DBI) library(RSQLite) con <- dbConnect("SQLite", dbname = database) query <- dbSendQuery(con, paste("SELECT * FROM ", table, ";", sep="")) result <- fetch(query, n = -1, encoding="utf-8") dbClearResult(query) dbDisconnect(con) return(result) } But now it seams it generates an error album <- sqLiteConnect("~/Downloads/ChinookDatabase1.3_Sqlite/Chinook_Sqlite.sqlite","Album") Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘dbConnect’ for signature ‘

How to connect R to MySQL? Failed to connect to database: Error: Plugin caching_sha2_password could not be loaded

╄→гoц情女王★ 提交于 2019-12-06 04:48:25
问题 I recently installed MySQL on my computer and am trying to connect RStudio to MySQL. I followed instructions in a book as well as instructions here. However, whenever I use dbConnect() or src_mysql in RStudio , I get this error message: Error in .local(drv, ...) : Failed to connect to database: Error: Plugin caching_sha2_password could not be loaded: The specified module could not be found For example, I might login to MySQL using the command prompt in Windows mysql -u username -p and create