-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathetl.rb
More file actions
25 lines (16 loc) · 655 Bytes
/
etl.rb
File metadata and controls
25 lines (16 loc) · 655 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# encoding: UTF-8
require 'pg'
require 'mysql'
con_my = Mysql.new('localhost','root','123qwe','ingrafprod')
result = con_my.query('SELECT * FROM in_sostenedor')
con_pg = PGconn.connect('localhost',5432,nil,nil,'prueba','user_test','123qwe')
result.each_hash do |r|
rut = r['rut_sostenedor']
ape_paterno = r['apellido_paterno']
ape_materno = r['apellido_materno']
nombre = r['nombres']
direccion = r['direccion']
sql = "INSERT INTO sostenedores (rut_sostenedor,apellido_paterno,apellido_materno,nombres,direccion) VALUES ('#{rut}','#{ape_paterno}','#{ape_materno}','#{nombre}','#{direccion}')"
#puts sql
con_pg.exec(sql)
end