require(RPostgreSQL)
# 读入driver
drv = dbDriver("PostgreSQL")
# 填写连接信息
pgdb = dbConnect(drv, user="user", password="password",host="127.0.0.1")
# 查询语句
rs = dbSendQuery(pgdb, statement = "SQL语句")
# 收割结果
df = fetch(rs, n = -1)
# 其实可以直接执行查询返回结果
dbGetQuery(con, "SQL语句")
# 断开连接
dbDisconnect(con)
# 释放资源
dbUnloadDriver(drv)
阅读(5832) | 评论(0) | 转发(0) |