よしよしpg経由でSQLも動いた。後はHTMLから呼び出してみて表示できるかだな。何とかRubyのCGI動いた。 #! /usr/bin/ruby # encoding: utf-8 require 'pg' connection = PG::connect(:host => "localhost", :user => "user", :password => "passwd", :dbname => "dbname", :port => "XXXX") begin result = connection.exec("SELECT id, name FROM t_rubysample") result.each do |tuple| puts tuple['id'] +":" + tuple['name'] end ensure connection.finish end
よしよしpg経由でSQLも動いた。後はHTMLから呼び出してみて表示できるかだな。何とかRubyのCGI動いた。 #! /usr/bin/ruby # encoding: utf-8 require...
=======================================
http://ift.tt/1abnmbU
March 15, 2016 at 06:53PM
=======================================
よしよしpg経由でSQLも動いた。後はHTMLから呼び出してみて表示できるかだな。何とかRubyのCGI動いた。
#! /usr/bin/ruby
# encoding: utf-8
require 'pg'
connection = PG::connect(:host => "localhost", :user => "user", :password => "passwd", :dbname => "dbname", :port => "XXXX")
begin
result = connection.exec("SELECT id, name FROM t_rubysample")
result.each do |tuple|
puts tuple['id'] +":" + tuple['name']
end
ensure
connection.finish
end
#! /usr/bin/ruby
# encoding: utf-8
require 'pg'
connection = PG::connect(:host => "localhost", :user => "user", :password => "passwd", :dbname => "dbname", :port => "XXXX")
begin
result = connection.exec("SELECT id, name FROM t_rubysample")
result.each do |tuple|
puts tuple['id'] +":" + tuple['name']
end
ensure
connection.finish
end
http://ift.tt/1abnmbU
March 15, 2016 at 06:53PM
コメント
コメントを投稿