Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # simple pg tests for dynamic column types
- require 'rubygems'
- require 'pg'
- require 'pp'
- host = "localhost"
- port = "5432"
- dbname = "postgres"
- user = "user"
- pass = "pass"
- conn = PGconn.open(:dbname => dbname, :user => user, :pass => pass, :host => host, :port => port)
- # pp PGconn.conndefaults
- res = conn.exec('SELECT now()::timestamp AS right_now')
- # puts res.methods.sort
- puts res[0].inspect
- puts "tuple_count = " + res.num_tuples.to_s
- puts "type oid = " + res.ftype(0).to_s
- type = conn.exec("SELECT typname AS name FROM pg_type WHERE oid = #{res.ftype(0)}")
- puts "type = " + type[0][type.fields[0]].to_s
Add Comment
Please, Sign In to add comment