r-dbi

R DBI ODBC error: nanodbc/nanodbc.cpp:3110: 07009: [Microsoft][ODBC Driver 13 for SQL Server]Invalid Descriptor Index

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 15:37:07
问题 I continue to read the DBI/ODBC is faster than RODBC , so I tried as follows: require(DBI);require(odbc) con <- DBI::dbConnect(odbc::odbc(), dsn = 'SQLSERVER1', database = 'AcumaticaDB') I can make a successful connection to the DSN, but the following query: rs <- dbGetQuery(con, "SELECT * FROM inventoryitem") dbFetch(rs) gives me the following error: Error in result_fetch(res@ptr, n, ...) : nanodbc/nanodbc.cpp:3110: 07009: [Microsoft][ODBC Driver 13 for SQL Server]Invalid Descriptor Index

How to pass data.frame for UPDATE with R DBI

非 Y 不嫁゛ 提交于 2019-11-30 07:19:10
With RODBC , there were functions like sqlUpdate(channel, dat, ...) that allowed you pass dat = data.frame(...) instead of having to construct your own SQL string. However, with R's DBI , all I see are functions like dbSendQuery(conn, statement, ...) which only take a string statement and gives no opportunity to specify a data.frame directly. So how to UPDATE using a data.frame with DBI? Really late, my answer, but maybe still helpful... There is no single function (I know) in the DBI/odbc package but you can replicate the update behavior using a prepared update statement (which should work

How to pass data.frame for UPDATE with R DBI

有些话、适合烂在心里 提交于 2019-11-29 09:44:10
问题 With RODBC, there were functions like sqlUpdate(channel, dat, ...) that allowed you pass dat = data.frame(...) instead of having to construct your own SQL string. However, with R's DBI, all I see are functions like dbSendQuery(conn, statement, ...) which only take a string statement and gives no opportunity to specify a data.frame directly. So how to UPDATE using a data.frame with DBI? 回答1: Really late, my answer, but maybe still helpful... There is no single function (I know) in the DBI/odbc

Proper way to pass parameters to query in R DBI

安稳与你 提交于 2019-11-29 04:30:14
In perl/python DBI APIs have a mechanism to safely interpolate in parameters to an sql query. For example in python I would do: cursor.execute("SELECT * FROM table WHERE value > ?", (5,)) Where the second parameter to the execute method is a tuple of parameters to add into the sql query Is there a similar mechanism for R's DBI compliant APIs? The examples I've seen never show parameters passed to the query. If not, what is the safest way to interpolate in parameters to a query? I'm specifically looking at using RPostgresSQL. Just for completeness, I'll add an answer based on Hadley's comment.

Proper way to pass parameters to query in R DBI

不羁岁月 提交于 2019-11-27 18:15:39
问题 In perl/python DBI APIs have a mechanism to safely interpolate in parameters to an sql query. For example in python I would do: cursor.execute("SELECT * FROM table WHERE value > ?", (5,)) Where the second parameter to the execute method is a tuple of parameters to add into the sql query Is there a similar mechanism for R's DBI compliant APIs? The examples I've seen never show parameters passed to the query. If not, what is the safest way to interpolate in parameters to a query? I'm