diff --git a/golang_learn/data_func/go_to_mysql/demo/demo2.go b/golang_learn/data_func/go_to_mysql/demo/demo2.go index 2b49881..032b90a 100644 --- a/golang_learn/data_func/go_to_mysql/demo/demo2.go +++ b/golang_learn/data_func/go_to_mysql/demo/demo2.go @@ -26,6 +26,14 @@ func main() { fmt.Println(cc[0], cc[1], cc[2], cc[3], cc[4], cc[5], cc[6], cc[7]) } + rows, _ := db.Query("select id,name from nginxlog limit 10; ") + var id int + var name string + for rows.Next() { + err = rows.Scan(&id, &name) + fmt.Println(id, name) + } + d, _ := db.Query("select IFNULL(A0192E, '') from A01 where STATUS='1';") //返回所有列 dd, _ := d.Columns() diff --git a/golang_learn/data_func/go_to_mysql/demo_insert_massive_info/demo.go b/golang_learn/data_func/go_to_mysql/demo_insert_massive_info/demo.go index 2e88318..8cb6691 100644 --- a/golang_learn/data_func/go_to_mysql/demo_insert_massive_info/demo.go +++ b/golang_learn/data_func/go_to_mysql/demo_insert_massive_info/demo.go @@ -4,7 +4,6 @@ import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" - "github.com/satori/go.uuid" "strconv" "time" ) @@ -73,13 +72,13 @@ func sqlExec(job Job) { buf := make([]byte, 0, job.total) buf = append(buf, " insert into student(user_name) values "...) for i := 0; i < job.total; i++ { - myid, _ := uuid.NewV4() + /*myid, _ := uuid.NewV4() userName := myid.String() if i == job.total-1 { buf = append(buf, "('"+userName+"');"...) } else { buf = append(buf, "('"+userName+"'),"...) - } + }*/ } ss := string(buf) fmt.Println("第" + strconv.Itoa(job.n) + "次插入2.5万条数据!") diff --git a/golang_learn/data_office/gey_hzb_cleaning/main.exe.manifest b/golang_learn/data_office/gey_hzb_cleaning/main.exe.manifest new file mode 100644 index 0000000..c52acbc --- /dev/null +++ b/golang_learn/data_office/gey_hzb_cleaning/main.exe.manifest @@ -0,0 +1,21 @@ + + + + + + + + + \ No newline at end of file diff --git a/golang_learn/data_office/gey_hzb_cleaning/main.go b/golang_learn/data_office/gey_hzb_cleaning/main.go new file mode 100644 index 0000000..60f07b5 --- /dev/null +++ b/golang_learn/data_office/gey_hzb_cleaning/main.go @@ -0,0 +1,83 @@ +package main + +import ( + "database/sql" + _ "github.com/go-sql-driver/mysql" + "log" +) + +type B01 struct { + b0111 string + b0111n string +} + +func main() { + db, _ := sql.Open("mysql", "root:admin@tcp(127.0.0.1:35017)/hy_qggwy?charset=utf8") + + log.Println("开始执行人员信息清洗") + makeA0000(db) + log.Println("执行完成人员信息清洗,准备机构信息清洗") + b01 := B01{ + b0111: "001.001", + b0111n: "001.001", + } + makeB0111(db, &b01) + log.Println("执行完成机构信息清洗") +} + +func makeB0111(db *sql.DB, b01 *B01) { + +} + +func makeA0000(db *sql.DB) { + // 创建临时表 + db.Exec("drop table if exists a01_a01;") + db.Exec("create table a01_a01 (a0000o varchar(200),a0000n varchar(200),a5714n varchar(200),names varchar(200),paths varchar(200));") + + // 迁移数据 + db.Exec("delete from a01 where STATUS = 4;") + db.Exec("insert into a01_a01 select a0000,uuid(),'','','' from a01;") + + // 更新数据 + db.Exec("update a01_a01 set a0000n=upper(replace(a0000n, '-', '')) where 1=1;") + db.Exec("update a01,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a02,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a05,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a06,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a08,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a11,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a14,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a15,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a36,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a57,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a30,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a33,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a65,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") + db.Exec("update a99z1,a01_a01 a1 set a0000=a0000n where a0000o=a0000;") +} + +func UpdateB01B01(db *sql.DB, b0111n int, b0111o string) { + if b0111o == "" { + return + } + stmt, err := db.Prepare("update b01_b01 set b0111n=? where b0111o=?;") + if err != nil { + log.Fatal(err) + } + _, err = stmt.Exec(b0111n, b0111o) + if err != nil { + log.Fatal(err) + } +} + +var b0111 string +var rowNum int + +func QueryB01(db *sql.DB, b01 *B01) { + c, _ := db.Query("select b0111,@i:=@i+1 rownum from b01,(select @i:=0) rows where b0121='" + b01.b0111 + "' order by SORTID") + for c.Next() { + c.Scan(&b0111, &rowNum) + UpdateB01B01(db, rowNum, b01.b0111) + + } +} diff --git a/golang_learn/data_office/gey_hzb_cleaning/main.syso b/golang_learn/data_office/gey_hzb_cleaning/main.syso new file mode 100644 index 0000000..b620536 Binary files /dev/null and b/golang_learn/data_office/gey_hzb_cleaning/main.syso differ diff --git a/golang_learn/data_office/gey_hzb_cleaning/rc.ico b/golang_learn/data_office/gey_hzb_cleaning/rc.ico new file mode 100644 index 0000000..a06bf77 Binary files /dev/null and b/golang_learn/data_office/gey_hzb_cleaning/rc.ico differ