diff --git a/src/db/database-primitives.go b/src/db/database-primitives.go index c0e42d7..e70a27d 100644 --- a/src/db/database-primitives.go +++ b/src/db/database-primitives.go @@ -53,8 +53,12 @@ func (c *ConnectorGeneric) ExecuteSqlScript(runner *sqlScriptRunner) { } } -// startConnection this initializes, caches, and returns a connection for the desired database +// startConnection this initializes, caches, and returns a connection for the desired database. If a connection already exists, +// it will be terminated and a new connection will be opened. func (c *ConnectorGeneric) startConnection(dataBase string) { + if c.cachedConnection != nil { + c.returnConnection() + } db := createDbConnection(dataBase) c.cachedConnection = db } diff --git a/src/mercury/Interconnect.go b/src/mercury/Interconnect.go index 9d0aca3..8ca346a 100644 --- a/src/mercury/Interconnect.go +++ b/src/mercury/Interconnect.go @@ -52,7 +52,7 @@ func (ic *Interconnect) UpdateTimeEntries() { coroutineCount-- log.Printf("Currently pending goroutines: %d\n", coroutineCount) } - ic.InsightDBConnector.ExecuteSqlScript(db.NewRunner("insight", "create-insight-contribution-table.sql")) + ic.InsightDBConnector.ExecuteSqlScript(db.NewRunner("create-insight-contribution-table.sql", "insight")) } //