From bb4a0be4c6d9df964ee48fe7c4e73b6e9c8ef3da Mon Sep 17 00:00:00 2001 From: Nikhil Mathew <nikhilmat@gmail.com> Date: Fri, 10 Nov 2017 15:41:37 -0800 Subject: [PATCH] Add GetDB to mysql.GetDB --- go/mysql/utils.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/go/mysql/utils.go b/go/mysql/utils.go index 96e7fbc..577805b 100644 --- a/go/mysql/utils.go +++ b/go/mysql/utils.go @@ -33,6 +33,15 @@ func (this *ReplicationLagResult) HasLag() bool { return this.Lag > 0 } +func GetDB(mysql_uri string) (*gosql.DB, error) { + db, err := gosql.Open("mysql", mysql_uri) + if err == nil { + return db, nil + } else { + return nil, err + } +} + // GetReplicationLag returns replication lag for a given connection config; either by explicit query // or via SHOW SLAVE STATUS func GetReplicationLag(informationSchemaDb *gosql.DB, connectionConfig *ConnectionConfig) (replicationLag time.Duration, err error) {