rpostgresql

Exporting Table from R to PostgreSQL by RPostgreSQL

夙愿已清 提交于 2019-12-06 01:50:56
I am using RPostgreSQL I have done number of process and I got a table in R. I wanted to put this table in PostgreSQL from R for further analysis that I will use PostgreSQL codes. The problem is that when I have a table in R which doesn't exist in PostgreSQL, I cannot perform SQL Codes on it. Sample Table s_2 the data format is not data frame and temp is float and DateeTIMEE is timestamps: temp DateeTIMEE 1 -1.64 2007-09-29 00:01:09 2 -1.76 2007-09-29 00:03:09 3 -1.83 2007-09-29 00:05:09 4 -1.86 2007-09-29 00:07:09 5 -1.94 2007-09-29 00:09:09 6 -1.87 2007-09-29 00:11:09 7 -1.87 2007-09-29 00

Is there a specific way to handle timestamp columns in R when pulling data using RPostgreSQL?

核能气质少年 提交于 2019-12-04 21:20:15
问题 I'm trying to pull data from a PostgreSQL database and the results for a timestamp field are inconsistent. I'm not sure if I'm handling POSIXct results properly. Otherwise, I think I found a bug in the RPostgreSQL package. Here is the way to replicate the issue: Suppose there is a table in a postgres database with one field (run this in PostgreSQL): CREATE DATABASE mydb; CREATE TABLE test_table ( "DateTime" timestamp without time zone NOT NULL, CONSTRAINT "pk_test_table" PRIMARY KEY (

Can I run an SQL update statement using only dplyr syntax in R

情到浓时终转凉″ 提交于 2019-12-04 03:13:42
I need to update column values conditionnaly on other columns in some PostgreSQL database table. I managed to do it writing an SQL statement in R and executing it with dbExecute from DBI package. library(dplyr) library(DBI) # Establish connection with database con <- dbConnect(RPostgreSQL::PostgreSQL(), dbname = "myDb", host="localhost", port= 5432, user="me",password = myPwd) # Write SQL update statement request <- paste("UPDATE table_to_update", "SET var_to_change = 'new value' ", "WHERE filter_var = 'filter' ") # Back-end execution con %>% dbExecute(request) Is it possible to do so using

Install RPostgreSQL on RHEL 6.5 libpq-fe.h Error

烂漫一生 提交于 2019-12-03 16:49:55
问题 I have RHEL 6.5 Server with an installation of R (3.1.1) & RStudioServer (0.98.1062) I have postgresql-9.3 installed and handling a large database. In order to connect R to PostgreSQL, I have in the past used the RPostgreSQL (still do on my CentOS 7 Workstation). However, attempting to compile under RHEL 6.5 I get an error In file included from RS-PQescape.c:7: RS-PostgreSQL.h:23:26: error: libpq-fe.h: No such file or directory The file is located on my system here: /usr/pgsql-9.3/include

Is there a specific way to handle timestamp columns in R when pulling data using RPostgreSQL?

故事扮演 提交于 2019-12-03 13:13:32
I'm trying to pull data from a PostgreSQL database and the results for a timestamp field are inconsistent. I'm not sure if I'm handling POSIXct results properly. Otherwise, I think I found a bug in the RPostgreSQL package. Here is the way to replicate the issue: Suppose there is a table in a postgres database with one field (run this in PostgreSQL): CREATE DATABASE mydb; CREATE TABLE test_table ( "DateTime" timestamp without time zone NOT NULL, CONSTRAINT "pk_test_table" PRIMARY KEY ("DateTime") ) WITH ( OIDS=FALSE ); ALTER TABLE test_table OWNER TO postgres; And let’s say there are a few

I cannot connect postgresql schema.table with dplyr package

孤街醉人 提交于 2019-12-02 18:20:35
Im trying to connect postgres with dplyr functions my_db <- src_postgres(dbname = 'mdb1252', user = "diego", password = "pass") my_db src: postgres 9.2.5 [postgres@localhost:5432/mdb1252] tbls: alf, alturas, asociad, atenmed, base, bfa_boys_p_exp, bfa_boys_z_exp, bfa_girls_p_exp, bfa_girls_z_exp, bres, c21200012012, c212000392011, c212000532011, c21200062012, c212006222012, c212007352012, c212012112013, c212012242012, c212012452012, c2222012242012, calles, cap, cap0110, casos_tbc_tr09, casos_tbctr09, casosvadela, catpo, cbcvl, cie09, cie10, cie103d, cie103dantigua, cie10c, cie9a, cie9mc,

How to use dynamic values while executing SQL scripts in R

混江龙づ霸主 提交于 2019-12-01 11:35:45
My R workflow now involves dealing with a lot of queries ( RPostgreSQL library). I really want to make code easy to maintain and manage in the future. I started loading large queries from separate .SQL files ( this helped) and it worked great. Then I started using interpolated values ( that helped) which means that I can write SELECT * FROM table WHERE value = ?my_value; and (after loading it into R) interpolate it using sqlInterpolate(ANSI(), query, value = "stackoverflow") . What happens now is I want to use something like this SELECT count(*) FROM ?my_table; but how can I make it work?

How to use dynamic values while executing SQL scripts in R

别等时光非礼了梦想. 提交于 2019-12-01 09:27:12
问题 My R workflow now involves dealing with a lot of queries ( RPostgreSQL library). I really want to make code easy to maintain and manage in the future. I started loading large queries from separate .SQL files (this helped) and it worked great. Then I started using interpolated values (that helped) which means that I can write SELECT * FROM table WHERE value = ?my_value; and (after loading it into R) interpolate it using sqlInterpolate(ANSI(), query, value = "stackoverflow") . What happens now

R RPostgreSQL Connect to Remote Postgres Database with SSL

孤街醉人 提交于 2019-12-01 04:57:51
I am trying to connect to a remote PostgreSQL database from within R using the RPostgreSQL package, and I am getting errors that appear to be related to the SSL settings for the connection. I have verified that I can connect from the command line using psql , so I know the connection is valid and accessible from my computer. My first attempt at connecting in R was the following (where <MyHost> and <MyPass> were filled out appropriately for my connection): library(RPostgreSQL) pg <- dbDriver( 'PostgreSQL' ) con = dbConnect( pg, host=<MyHost>, dbname='warehouse', user='warehouse', password=

Can't connect to AWS Redshift using RPostgreSQL

*爱你&永不变心* 提交于 2019-11-30 20:27:57
问题 I'm not able to connect to my AWS Redshift database using RPostgreSQL. Does anyone have an example of code that would work? library (RPostgreSQL) drv <- dbDriver("PostgreSQL") conn <- dbConnect(drv, "database.us-east-1.redshift.amazonaws.com", "jeffz", "PsWrd123") Error in postgresqlNewConnection(drv, ...) : RS-DBI driver: (could not connect database.us-east-1.redshift.amazonaws.com@PsWrd123 on dbname "database.us-east-1.redshift.amazonaws.com" Windows 7 postgresql-8.4-703.jdbc4 in drivers