Friday, January 2, 2015

RPostgreSQL

  1. Installation
    1. install.packages("RPostgreSQL")
    2. library(RPostgreSQL)
  2. Driver
    1. drv <- dbDriver("PostgreSQL")
    2. dbListConnections(drv)
    3. dbGetInfo(drv)
    4. summary(drv)
    5. dbUnloadDriver(drv)
  3. Connection
    1. con <- dbConnect (drv, user ="tester", password ="tester", dbname ="testDB", host ="IP Address")
    2. dbGetException(con)
    3. dbListResults(con)
    4. dbListTables(con)
    5. dbBeginTransaction(con)
    6. dbRollback(con)
    7. dbCommit(con)
    8. dbDisconnect(con)
    9. dbExistsTable(con, "table name")
    10. dbRemoveTable(con,"table name")
    11. dbListFields(con, "table name")
    12. df <- dbReadTable(con, "table name")
    13. dbWriteTable(con, "new table name", df)
    14. dbGetQuery(con, "select * from tableName")
  4. Result Set
    1. rs <- dbSendQuery(con, "select * from tableName")
    2. dbGetStatement(rs)
    3. dbColumnInfo(rs)
    4. dbGetRowsAffected(rs)
    5. dbHasCompleted(rs)
    6. dbGetRowCount(rs)
    7. dbClearResult(rs)
    8. fetch(rs, n = 1)
    9. fetch(rs, n = -1)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.