Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "pg"
- begin
- con = PG.connect(dbname: 'postgres')
- con.exec('CREATE DATABASE app_db')
- con_app = PG.connect(dbname: 'app_db')
- con_app.exec('DROP TABLE IF EXISTS Names')
- con_app.exec('CREATE TABLE Names(Id INTEGER, Name VARCHAR(20))')
- con_app.exec("INSERT INTO Names VALUES(1, 'SomeName')")
- result = con_app.exec('SELECT * FROM Names')
- result.each { |name| puts "#{name['id']}, #{name['name']}" }
- con_app.exec('DROP TABLE Names')
- con_app&.close
- con.exec('DROP DATABASE app_db')
- con&.close
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement