Browse Source

暂失败洗数据操作

master
viviman 3 years ago
parent
commit
726b692afc
  1. 8
      golang_learn/data_func/go_to_mysql/demo/demo2.go
  2. 5
      golang_learn/data_func/go_to_mysql/demo_insert_massive_info/demo.go
  3. 21
      golang_learn/data_office/gey_hzb_cleaning/main.exe.manifest
  4. 83
      golang_learn/data_office/gey_hzb_cleaning/main.go
  5. BIN
      golang_learn/data_office/gey_hzb_cleaning/main.syso
  6. BIN
      golang_learn/data_office/gey_hzb_cleaning/rc.ico

8
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()

5
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万条数据!")

21
golang_learn/data_office/gey_hzb_cleaning/main.exe.manifest

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="x86"
name="controls"
type="win32"
></assemblyIdentity>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>

83
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)
}
}

BIN
golang_learn/data_office/gey_hzb_cleaning/main.syso

Binary file not shown.

BIN
golang_learn/data_office/gey_hzb_cleaning/rc.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Loading…
Cancel
Save