Guest User

Untitled

a guest
Nov 21st, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. library(RPostgreSQL) #import the library
  2. driver <- dbDriver('PostgreSQL') #define the database driver
  3. db <- dbConnect(driver, host='foobar_host', #set the host to the postgreSQL IP or alias
  4. user='foo_bar', #input username
  5. password='my_secret_code', #input your password
  6. dbname='my_gp_db') #input the name of the databse
  7.  
  8.  
  9.  
  10. myquery <- "SELECT
  11. col_one
  12. ,col_two
  13. ,col_three
  14. FROM table_one a
  15. INNER JOIN table_two b
  16. ON a.id = b.a_id
  17. WHERE
  18. a.created_date > 2012
  19. LIMIT 100;"
  20.  
  21. my.data <- dbGetQuery(db, myquery) #assign results to a vector
Add Comment
Please, Sign In to add comment