I have a problem with my R program querying a PostgreSQL database. Here is the code
### Here we assume that myuser, mypassword, db, host_db and db_port
### have been defined in previous lines in the code
db_con <- dbConnect(
…
I have a dataframe in a database with a date dimension that I pulled using RPostgres. Each 'date' is in the format 'YYYY-MM-DD. I'd like to add a new column of dates (labeled 'lookback_date') that are one year earlier than the initial dates.
To be…
I try connect to my table in postgres.
Here screen of my db.
So i need dbo.social and table profiles.
So to do this, i try
library(RPostgres)
library(DBI)
pw<- {
"1234"
}
con <- dbConnect(RPostgres::Postgres()
,…
I am trying to import a dataset (with many csv files) into r and afterwards write the data into a table in a postgresql database.
I successfully connected to the database, created a loop to import the csv files and tried to import.
R then returns an…
I have a dataframe df with an id column. This maps to many rows 1:n) in my database table. Querying each ID sequentially takes about an hour to complete, so I'm trying to run multiple queries at once using the doparallel package. There is overhead…
I'm building a R package that connects to a PostgreSQL database. I'd like to explicitly state package::function for my functions that depend on external packages. Here is a function from that package:
connect_aact <- function(user, password) {
…
I am using RPostgresql and DBI in RStudio.
library(RPostgreSQL)
library(DBI)
#save password
prod_pw <- {
"my_pass"
}
# make db connection
con <- dbConnect(RPostgreSQL::PostgreSQL(), dbname = 'my_dbname',
host =…
How to get the only particular table column names using R?
Sample code:
df<-dbgetQuery(con,"select * from table 1 limit 100")
colnames(df)
Is there any alternative for the above query?
I have a bunch of identical schemas in PostgreSQL I want to get data from. I use RpostgreSQL inside a loop this way
``` r
results <- data.frame()
for (schema in schema.list ) {
con <- DBI::dbConnect(RPostgreSQL::PostgreSQL(),
…
When connecting to a database using the dbConnect function in the DBI package, what are the best practices for securing logon information such as database name, username and password?
Entering logon information as a character text such…
I am trying to transfer data from the Thingspeak API into a postgres database. The API limits each request to 8000 observations, but I need to pull millions! I'm using R to iteratively pull from the API, do a bunch of wrangling, and then submit the…
I am using R version noted below:
R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)
R is free software and comes with ABSOLUTELY NO…
On my Win 7 Ent x64 I installed RStudio R-3.4.2.
I installed few packages that I need (RPostgreSQL, sqldf, etc..)
But when I'm executing code, these libraries give me errors:
library(RPostgreSQL)
Error: package ‘RPostgreSQL’ was installed by an R…
I have a shiny dashboard on a Ubuntu server that connects to the 'local' PostgreSQL db to collect data. It works perfectly well when I launch the dashboard from my R-Studio environment (on the same server), but the dashboard fails to load when I…
I have a postgresql database connection and want to get a table from the database. Presumably it's good practice to keep the connection info in a different file?
I have two files just now:
#getthetable.R
library(tidyverse)
library(dbplyr)
##…