rpostgresql

Using sqldf and RPostgreSQL together

不打扰是莪最后的温柔 提交于 2019-11-30 08:33:20
When using RPostgreSQL I find that I cannot use sqldf in the same way. For example if I load the library and read in data into a data frame using the following code: library(RPostgreSQL) drv <- dbDriver("PostgreSQL") con <- dbConnect(drv, host="localhost", user="postgres", password="xxx", dbname="yyy", port="5436") rs <- dbSendQuery(con, "select * from table"); df<- fetch(rs, n = -1); dbClearResult(rs) dbDisconnect(con) I know have the contents of this table in the dataframe df . However if I want to run a SQL command using sqldf I would previously do something like this: sqldf("SELECT * FROM

Using sqldf and RPostgreSQL together

被刻印的时光 ゝ 提交于 2019-11-29 11:51:06
问题 When using RPostgreSQL I find that I cannot use sqldf in the same way. For example if I load the library and read in data into a data frame using the following code: library(RPostgreSQL) drv <- dbDriver("PostgreSQL") con <- dbConnect(drv, host="localhost", user="postgres", password="xxx", dbname="yyy", port="5436") rs <- dbSendQuery(con, "select * from table"); df<- fetch(rs, n = -1); dbClearResult(rs) dbDisconnect(con) I know have the contents of this table in the dataframe df . However if I

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.

Can not connect PostgreSQL(over SSL) with RPostgresql on Windows

只谈情不闲聊 提交于 2019-11-28 02:28:18
I can not connect PostgreSQL(on Heroku) with RPostgreSQL on Windows(64bit). I can connect local postgresql(not ssl) with RPostgreSQL on Windows. I can connect PostgreSQL on Heroku from PgAdmin on Windows. I can connect PostgreSQL on Heroku with RPostgreSQL on OSX and Linux. Only RPostgreSQL on Windows can not connect Heroku PostgreSQL. Error message is: Error in postgresqlNewConnection(drv, ...) : RD-DBI driver: (could not connect....xxxxx Is there any solution? Philippe Marchand It's related to this issue: Can't create dbConnect to Postgres with SSL . One solution that worked for me (also

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

Can not connect PostgreSQL(over SSL) with RPostgresql on Windows

那年仲夏 提交于 2019-11-27 04:54:30
问题 I can not connect PostgreSQL(on Heroku) with RPostgreSQL on Windows(64bit). I can connect local postgresql(not ssl) with RPostgreSQL on Windows. I can connect PostgreSQL on Heroku from PgAdmin on Windows. I can connect PostgreSQL on Heroku with RPostgreSQL on OSX and Linux. Only RPostgreSQL on Windows can not connect Heroku PostgreSQL. Error message is: Error in postgresqlNewConnection(drv, ...) : RD-DBI driver: (could not connect....xxxxx Is there any solution? 回答1: It's related to this