1.安装PG模块
gem install pg
2.访问PostgreSQL
require 'pg'
conn = PGconn.open(:dbname => 'test')
res = conn.exec('SELECT 1 AS a, 2 AS b, NULL AS c')
res.getvalue(0,0) # '1'
res[0]['b'] # '2'
res[0]['c'] # nil
~~THE END~~
尹曙光
转载于:https://blog.51cto.com/yinshuguang/1250496
本文介绍如何在Ruby环境中安装PG模块,并通过示例演示如何使用该模块连接到PostgreSQL数据库并执行基本查询。

2239

被折叠的 条评论
为什么被折叠?



