-
Notifications
You must be signed in to change notification settings - Fork 125
/
geo.go
29 lines (24 loc) · 672 Bytes
/
geo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package geo
import (
"database/sql"
_ "github.com/erikstmartin/go-testdb"
_ "github.com/lib/pq"
_ "github.com/ziutek/mymysql/godrv"
)
// HandleWithSQL retrieves the SQL configuration specified in config.yml
// that resides at the root level of the project.
// Returns a pointer to a SQLMapper if successful, or an error
// if there is an issue opening a database connection.
func HandleWithSQL() (*SQLMapper, error) {
sqlConf, sqlConfErr := GetSQLConf()
if sqlConfErr == nil {
s := &SQLMapper{conf: sqlConf}
db, err := sql.Open(s.conf.driver, s.conf.openStr)
if err != nil {
panic(err)
}
s.sqlConn = db
return s, err
}
return nil, sqlConfErr
}