I need to get a list of schemas (databases) in Postgresql using Sequel. My client can perform the SQL, but for some reason, my connection in IRB doesn’t want see anything.
require ‘sequel’
require ‘pg’
d = Sequel.connect('postgres://dingbat:password@0.0.0.0/postgres')
r = d.run('select datname, datistemplate from pg_database where datistemplate = false’)
puts r.inspect # => nil
Any workarounds that anybody knows about? I appreciate any input.
DB = Sequel.connect('postgres://dingbat:password@0.0.0.0/postgres')
databases = DB['select datname, datistemplate from pg_database where
datistemplate = false']
databases.each { |db| p db }
I need to get a list of schemas (databases) in Postgresql using Sequel.
My client can perform the SQL, but for some reason, my connection in IRB
doesn’t want see anything.
require ‘sequel’
require ‘pg’
d = Sequel.connect('postgres://dingbat:password@0.0.0.0/postgres')
r = d.run('select datname, datistemplate from pg_database where
datistemplate = false’)
puts r.inspect # => nil
Any workarounds that anybody knows about? I appreciate any input.
Exactly along the lines of which I was ‘using’, but IRB is my first go-to and it was closed. My postgresql client showed otherwise. So that’s the confusion.
databases.size # => nil
Confusing.
Anyway, I hard coded the database (schema) names, and all is good.
Thanks
···
On Sep 30, 2016, at 1:28 AM, Aleksey Ivanov <ialexxei@gmail.com> wrote:
DB = Sequel.connect('postgres://dingbat:password@0.0.0.0/postgres')
databases = DB['select datname, datistemplate from pg_database where datistemplate = false']
databases.each { |db| p db }