Skip to content

Commit bb4a0be

Browse files
committed
Add GetDB to mysql.GetDB
1 parent 338a439 commit bb4a0be

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

go/mysql/utils.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ func (this *ReplicationLagResult) HasLag() bool {
3333
return this.Lag > 0
3434
}
3535

36+
func GetDB(mysql_uri string) (*gosql.DB, error) {
37+
db, err := gosql.Open("mysql", mysql_uri)
38+
if err == nil {
39+
return db, nil
40+
} else {
41+
return nil, err
42+
}
43+
}
44+
3645
// GetReplicationLag returns replication lag for a given connection config; either by explicit query
3746
// or via SHOW SLAVE STATUS
3847
func GetReplicationLag(informationSchemaDb *gosql.DB, connectionConfig *ConnectionConfig) (replicationLag time.Duration, err error) {

0 commit comments

Comments
 (0)