-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathetl.go
50 lines (44 loc) · 883 Bytes
/
etl.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package goquery
type TransferOptions struct {
CreateTable bool
CommitSize int
}
type ETL struct {
source DataStore
sourceStmtKey string
dest DataStore
destStmtKey string
options TransferOptions
}
/*
func (etl *ETL) copyData(qi QueryInput) (err error) {
rows, err := etl.source.FetchRows(qi)
if err != nil {
return err
}
defer rows.Close()
typ := reflect.TypeOf(qi.DataSet.Attributes()).Elem()
typeP := reflect.New(typ).Elem().Addr()
structRef := typeP.Interface()
var i int = 0
for rows.Next() {
i++
err = rows.StructScan(structRef)
if err != nil {
panic(err)
}
if i%etl.options.CommitSize == 0 {
err = etl.dest.Commit()
if err != nil {
panic(err)
}
err = etl.dest.StartTransaction()
if err != nil {
panic(err)
}
}
etl.dest.CopyRow(table, i, structRef)
}
return nil
}
*/