#加载库
require(RPostgreSQL)
# 读入driver
drv = dbDriver("PostgreSQL")
# 填写连接信息
pgdb_con = dbConnect(drv, user="user", password="password",host="127.0.0.1")
# 查询语句
rs = dbSendQuery(pgdb_con, statement = "SQL语句")
# 收割结果
df = fetch(rs, n = -1)
# 其实可以直接执行查询返回结果
dbGetQuery(pgdb_con, "SQL语句")
# 断开连接
dbDisconnect(pgdb_con)
# 释放资源
dbUnloadDriver(drv)
R语言操作postgresql
最新推荐文章于 2022-05-27 15:22:25 发布