Browse Source

完善部分代码

master
VIVIMAN 3 years ago
parent
commit
7dd0068fa6
  1. 4
      golang_learn/data_office/get_hy_sql/main.go

4
golang_learn/data_office/get_hy_sql/main.go

@ -22,7 +22,7 @@ import (
//存在所有对象信息 - 集合 //存在所有对象信息 - 集合
func main() { func main() {
sqlPath := "D:/hy_qggwy_kk.sql" sqlPath := "./hy_qggwy_kk.sql"
db, _ := sql.Open("mysql", "root:admin@tcp(127.0.0.1:35017)/hy_qggwy?charset=utf8") db, _ := sql.Open("mysql", "root:admin@tcp(127.0.0.1:35017)/hy_qggwy?charset=utf8")
log.Print("操作数据库连接:", db) log.Print("操作数据库连接:", db)
@ -128,7 +128,7 @@ func runSQL(mysqlPath, sqlPath string) {
log.Print("调用执行对应的SQL脚本:", sqlPath) log.Print("调用执行对应的SQL脚本:", sqlPath)
c := exec.Command("cmd", "/C", mysqlPath+"mysql -uroot -padmin hy_qggwy < "+sqlPath) c := exec.Command("cmd", "/C", mysqlPath+"mysql -uroot -padmin hy_qggwy < "+sqlPath)
if err := c.Run(); err != nil { if err := c.Run(); err != nil {
log.Fatal("执行时发生异常!异常为:", err) log.Print("【不影响执行】执行时发生异常!异常为:", err)
} }
log.Print("预置脚本数据成功!") log.Print("预置脚本数据成功!")
} }

Loading…
Cancel
Save