ruby - Insert Into DB using Sequel -
i want insert data postgres db using sequel. have pursued 2 approaches, none has yielded results want.
my first approach "querying in sequel":
connection = sequel.connect('postgres://admin:admin@localhost:5432/test_tcp') insert_values = connection["insert cards (:card_number, :phone_number, :uuid, :created_at, :updated_at) values (?)", '766877868', '256700000000', '9043', '2016-09-07 11:11:31 +0300', '2016-09-07 11:11:31 +0300'] insert_values.insert connection.close
my second approach "inserting records":
connection = sequel.connect('postgres://admin:admin@localhost:5432/test_tcp') cards = connection.from(:cards) cards.insert(:id => 1, :card_number => "13668389", :phone_number => "256700000000", :uuid => "9014", :created_at => '2016-09-07 11:11:31 +0300', :updated_at => '2016-09-07 11:11:31 +0300') connection.close
simply following code below worked me:
connection = sequel.connect('postgres://admin:admin@localhost:5432/test_tcp') cards = connection.from(:cards) cards.insert(id: 1, card_number: "13668389", phone_number: "256700000000", uuid: "9014", created_at: '2016-09-07 11:11:31', updated_at: '2016-09-07 11:11:31') connection.close
changing values :created_at
, :updated_at
store time stamps without time zones did trick.
it weird how sequel wouldn't output error warn this.
Comments
Post a Comment