I am trying to get the row counts of all my tables with a query and I want to save the results in a dataframe. Right now, it only saves one value and I'm not sure what the issue is. Thanks for any help.
schema <- "test"
table_prefix <-…
Question: How do I pass a variable in the RPostgreSQL query?
Example: In the example below I try to pass the date '2018-01-03' to the query
library(RPostgreSQL)
dt <- '2018-01-03'
connect <- dbConnect(PostgreSQL(),
…
I have a mixed case column in my_table that can only be queried using double quotes in psql. For example:
select "mixedCase" from my_table limit 5; would be the correct way to write the query in psql, and this returns records successfully
However,…
So I'm using these three packages in R in order to connect to some databases and query them:
library(rJava)
library(RJDBC)
library (RPostgreSQL)
id_query <- dbGetQuery(conn2, "SELECT b.id id FROM table1 a LEFT JOIN table2 b ON a.id = b.id WHERE…
I have a shinydashboard (using the shinydashboard package here) where I take input from the user for his username and password, connect to Redshift using it,execute a Redshift query using his credentials and then want to display the output of the…
I am trying to write a prepared statement with dbSendQuery. My issue is that the data frame of inputs are converted to numeric values, but two of the three inputs are dates. This results in the following error message:
Warning: Error in…
I'm using PostgresSQL 10 and RPostgreSQL package in R.
I create a new table:
CREATE TABLE people (
id integer NOT NULL,
name character varying,
birthdate date,
deathdate date
);
Then attempt to copy the file :
COPY people (id,…
I have two columns of interest ID and Deadline:
ID Deadline (DD/MM/YYYY)
1 01/01/2017
1 05/01/2017
1 04/01/2017
2 02/01/2017
2 03/01/2017
2 06/02/2017
2 08/03/2017
Each ID can have multiple (n)…
I used R and DBI to query data from a PostgreSQL but got corrupted results with weird characters. I check both server encoding and client encoding, and they are all UTF-8. Here's what I did
Connect to the db
library(DBI)
conn <- dbConnect(
drv…
I am trying to:
dbGetQuery(conn, "SELECT * FROM test WHERE id in (select fid from test2)")
However, I get the error:
RS-DBI driver: (could not Retrieve the result : ERROR: column "fid" does not exist
Is nested selects not supported by…
I need to access different databases which contain symbols $ and € (or other currencies)
library(RPostgreSQL)
get_connection <- function(connection = current_connection)
{
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname = connection,
…
I am to connect to AWS Redshift using dbConnect query
conn_loss <- dbConnect(drv, host="hydrogen2.YOURHOST.us-east-1.redshift.amazonaws.com",
port="5439",
dbname="mydb",
user="master_user",
…
I want to use the megaptera::dbPars() function as per the megaptera vignette, however I keep receiving errors when executing the function. My PostgreSQL can be accessed through pgAdmin 4 as well as through the command line and works fine. The…
I'm trying to import a very large data that includes timestamp formatted as "2015-08-31 07:23:25.3"
The table has almost 2.5mil rows and when I import it into the dataframe, it loses time.
table1 <- dbReadTable(db_connection, "table_name")
Above is…
I want to create a covariance matrix from a data frame which is not yet suitable for creating one.
After using RPostgreSQL to query the database I have a data frame of the following type:
pg_id item_id value date
1 …