1
|
package starrocks
|
1
|
package starrocks
|
2
|
|
2
|
|
3
|
-import (
|
|
|
4
|
- "database/sql"
|
|
|
5
|
- "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
|
|
|
6
|
- "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
|
|
|
7
|
- "time"
|
|
|
8
|
-)
|
|
|
9
|
-
|
|
|
10
|
-var DBOfficial *sql.DB
|
|
|
11
|
-
|
|
|
12
|
-func InitDBOfficial() error {
|
|
|
13
|
- var err error
|
|
|
14
|
- //sql.Register("mysql-star", &mysql.MySQLDriver{})
|
|
|
15
|
- DBOfficial, err = sql.Open("mysql", constant.STARROCKS_MYSQL_DATA_SOURCE)
|
|
|
16
|
- if err != nil {
|
|
|
17
|
- return err
|
|
|
18
|
- }
|
|
|
19
|
- // See "Important settings" section.
|
|
|
20
|
- DBOfficial.SetConnMaxLifetime(time.Minute * 3)
|
|
|
21
|
- DBOfficial.SetMaxOpenConns(2)
|
|
|
22
|
- DBOfficial.SetMaxIdleConns(2)
|
|
|
23
|
- return nil
|
|
|
24
|
-}
|
|
|
25
|
-
|
|
|
26
|
-func ExecOfficial(sql string) error {
|
|
|
27
|
- log.Logger.Debug(sql)
|
|
|
28
|
- result, err := DBOfficial.Exec(sql)
|
|
|
29
|
- if err != nil {
|
|
|
30
|
- log.Logger.Error("exec error", map[string]interface{}{"err": err.Error()})
|
|
|
31
|
- return err
|
|
|
32
|
- }
|
|
|
33
|
- _, err = result.RowsAffected()
|
|
|
34
|
- if err != nil {
|
|
|
35
|
- log.Logger.Error("result error", map[string]interface{}{"result": err.Error()})
|
|
|
36
|
- return err
|
|
|
37
|
- }
|
|
|
38
|
- return nil
|
|
|
39
|
-} |
3
|
+//import (
|
|
|
4
|
+// "database/sql"
|
|
|
5
|
+// "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
|
|
|
6
|
+// "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
|
|
|
7
|
+// "time"
|
|
|
8
|
+//)
|
|
|
9
|
+//
|
|
|
10
|
+//var DBOfficial *sql.DB
|
|
|
11
|
+//
|
|
|
12
|
+//func InitDBOfficial() error {
|
|
|
13
|
+// var err error
|
|
|
14
|
+// //sql.Register("mysql-star", &mysql.MySQLDriver{})
|
|
|
15
|
+// DBOfficial, err = sql.Open("mysql", constant.STARROCKS_MYSQL_DATA_SOURCE)
|
|
|
16
|
+// if err != nil {
|
|
|
17
|
+// return err
|
|
|
18
|
+// }
|
|
|
19
|
+// // See "Important settings" section.
|
|
|
20
|
+// DBOfficial.SetConnMaxLifetime(time.Minute * 3)
|
|
|
21
|
+// DBOfficial.SetMaxOpenConns(2)
|
|
|
22
|
+// DBOfficial.SetMaxIdleConns(2)
|
|
|
23
|
+// return nil
|
|
|
24
|
+//}
|
|
|
25
|
+//
|
|
|
26
|
+//func ExecOfficial(sql string) error {
|
|
|
27
|
+// log.Logger.Debug(sql)
|
|
|
28
|
+// result, err := DBOfficial.Exec(sql)
|
|
|
29
|
+// if err != nil {
|
|
|
30
|
+// log.Logger.Error("exec error", map[string]interface{}{"err": err.Error()})
|
|
|
31
|
+// return err
|
|
|
32
|
+// }
|
|
|
33
|
+// _, err = result.RowsAffected()
|
|
|
34
|
+// if err != nil {
|
|
|
35
|
+// log.Logger.Error("result error", map[string]interface{}{"result": err.Error()})
|
|
|
36
|
+// return err
|
|
|
37
|
+// }
|
|
|
38
|
+// return nil
|
|
|
39
|
+//} |