Skip to content

Commit

Permalink
part 3
Browse files Browse the repository at this point in the history
  • Loading branch information
idjohnson committed Jul 21, 2023
1 parent cb6610d commit 92c25c7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion helloworld.rb
Expand Up @@ -17,15 +17,19 @@
puts 'Successfully created connection to database.'

resultSet = connection.exec('SELECT * from demotable;')
outStr = "<table><tr><th>id</th><th>name</th></tr>"
resultSet.each do |row|
puts 'Data row = (%s, %s)' % [row['id'], row['name']]
row_data = "<tr><td>#{row['id']}</td><td>#{row['name']}}</td></tr>"
outStr += "#{row_data}"
end
outStr += "</table>"
outStr

rescue PG::Error => e
puts e.message

ensure
connection.close if connection
end
'Hello World!'
end

0 comments on commit 92c25c7

Please sign in to comment.