Skip to content

Commit a6e9b2a

Browse files
committed
修改默认最大包大小
1 parent 469b513 commit a6e9b2a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

orm/db.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ func (db *DB) GetConnection() (*sql.DB, error) {
4949
return stmtDB, nil
5050
}
5151

52+
const (
53+
maxAllowedPacket = 134217728
54+
)
55+
5256
func (db *DB) getDSN() string {
53-
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/", db.UserName, db.Passwd, db.IP, db.Port)
57+
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/?maxAllowedPacket=%d", db.UserName, db.Passwd, db.IP, db.Port, maxAllowedPacket)
5458

5559
if len(db.DBName) > 0 {
5660
dsn = fmt.Sprintf("%s%s", dsn, db.DBName)

0 commit comments

Comments
 (0)