conn = PGconn.connect(pghost,pgport,pgoptions,pgtty,dbname)
open(".ftppasswd") { |file|
file.each_line { |line|
next if /^\s*#/ =~ line
username, password, = line.chomp.split(’:’)
res="CREATE TABLE ", username, " (id SERIAL, a char)"
result = conn.exec ($res)
^^^^^^^line 19
}
}
[kosha@kosha ruby_test]$ ./create_table.ruby
./create_table.ruby:19:in exec': wrong argument type nil (expected String) (TypeError) from ./create_table.ruby:19 from ./create_table.ruby:11:ineach_line’
from ./create_table.ruby:11
from ./create_table.ruby:10:in `open’
from ./create_table.ruby:10
[kosha@kosha rubye sample]$
res="CREATE TABLE “, username, " (id SERIAL, a char)”
Well, here res" will be an Array not a String. Probably you want +’
rather than `,’
result = conn.exec ($res)
You use $res', which is not initialized, rather than res’
Guy Decoux
[kosha@kosha rubye sample]$ ./create_table.ruby
./create_table.ruby:19:in exec': wrong argument type Array (expected String) (TypeError) from ./create_table.ruby:19 from ./create_table.ruby:11:in each_line’
from ./create_table.ruby:11
from ./create_table.ruby:10:in `open’
from ./create_table.ruby:10
[kosha@kosha rubye sample]$
Another error)…i think that res must be string but not array…or i
mistaking ?