Re: [R] Issues with RPostgres

2015-08-27 Thread John McKown
On Thu, Aug 27, 2015 at 2:29 PM, Abraham Mathew mathewanalyt...@gmail.com
wrote:

 I have a user-defined function that I'm using alongside a postgresql
 connection to
 summarize some data. I've connected to the local machine with no problem.
 However,
 the connection keeps throwing the following error when I attempt to use it.
 Can anyone point
 to what I could be doing wrong.

  ds_summary(con, test, vars=c(Age), y=c(Class))
 Error in postgresqlNewConnection(drv, ...) :
   RS-DBI driver: (could not connect postgres@localhost on dbname test
 )


 con is the connection


​It would be helpful to see the assignment to con as well as any other
assignments related to this. If you are using the DBI package, then what I
am talking about would be something like:

drv-dbDriver(PgSQL)
con-dbConnect(drb,user=...,password=...,dbname=test');

From looking at the message, it appears to me that you are trying to
connect to PostgreSQL as the postgres user. That just seems wrong to me.
Normally that user is only for administration purposes. It does not
normally contain user tables such as test. I would think that what you
needed would be your PostgreSQL user id. Or the id of the owner of the
test table.​




 test is the database table
 age is the attribute that will be summarized
 class is the response variable

 Can anyone help?


 --


 *Abraham MathewData Ninja and Statistical Modeler*



 *Minneapolis, MN720-648-0108@abmathewksAnalytics_Blog
 https://mathewanalytics.wordpress.com/*

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Issues with RPostgres

2015-08-27 Thread Hadley Wickham
On Thu, Aug 27, 2015 at 3:46 PM, John McKown
john.archie.mck...@gmail.com wrote:
 On Thu, Aug 27, 2015 at 2:29 PM, Abraham Mathew mathewanalyt...@gmail.com
 wrote:

 I have a user-defined function that I'm using alongside a postgresql
 connection to
 summarize some data. I've connected to the local machine with no problem.
 However,
 the connection keeps throwing the following error when I attempt to use it.
 Can anyone point
 to what I could be doing wrong.

  ds_summary(con, test, vars=c(Age), y=c(Class))
 Error in postgresqlNewConnection(drv, ...) :
   RS-DBI driver: (could not connect postgres@localhost on dbname test
 )


 con is the connection


 It would be helpful to see the assignment to con as well as any other
 assignments related to this. If you are using the DBI package, then what I
 am talking about would be something like:

 drv-dbDriver(PgSQL)
 con-dbConnect(drb,user=...,password=...,dbname=test');

FWIW the best way to create a connection is:

library(DBI)
con - dbConnect(RPostgreSQL::PostgreSQL(), ...)

The older string based approach is not advised.

Hadley
-- 
http://had.co.nz/

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.