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