Create table and insert data in postgres : postgres « Database « Ruby






Create table and insert data in postgres


require 'postgres'
conn = PGconn.connect("",5432, "", "", "testdb")

conn.exec("create table rtest ( number integer default 0 );")
conn.exec("insert into rtest values ( 99 )")
res = conn.query("select * from rtest")
# res id [["99"]]

 








Related examples in the same category

1.create the table