R(R Studio) Connection with PostgreSQL

R(R Studio) Connection with PostgreSQL: We have to use R package: RPostgreSQL

1. Install RPostgreSQL package

install.packages(“RPostgreSQL”)

Installing package into ‘C:/Users/pinnapav/Documents/R/win-library/3.3’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/RPostgreSQL_0.6-2.zip' Content type 'application/zip' length 433117 bytes (422 KB) downloaded 422 KB package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\pinnapav\AppData\Local\Temp\RtmpWcxGA7\downloaded_packages

2. Load RPostgreSQL library.

library(RPostgreSQL)

3. Add PostgreSQL driver

driver< -dbDriver('PostgreSQL') 4. Create connection string. Connection to the database dvdrental on server localhost with port number 5432 and user 'postgres'. connection<-dbConnect(driver,dbname="dvdrental",host="localhost",port=5432,user="postgres",password="postgres@5432") 5. Check the table name 'rental' exist in the database 'dvdrental or not. dbExistsTable(connection,'rental') [1] TRUE R(R Studio) Connection with PostgreSQL

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools
%d bloggers like this: