# -*- encoding : utf-8 -*-
require 'pg'
PG_CONN = PG.connect(
dbname: 'minicron',
host: '127.0.0.1',
port: 5432,
user: 'postgres',
password: 'www.pp.c0m'
)
PG_CONN.prepare(
'statement1',
"select * from jobs"
)
PG_CONN.prepare(
'statement2',
"update public.jobs set job_hash = $1 where name is not null and command = $2"
)
aa = PG_CONN.exec_prepared('statement1')
aa.each do |a|
PG_CONN.exec_prepared('statement2',[a['job_hash'], a['command']])
end