Skip to content

Commit

Permalink
Add an exec method
Browse files Browse the repository at this point in the history
  • Loading branch information
cinic0101 committed Feb 15, 2019
1 parent 8e2d306 commit a310661
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sqlconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ func (d *Databases) NewInstance(db string) *DBConn {
return dbInstances[strings.ToLower(db)]
}

func (d *DBConn) Exec(query string, args ...interface{}) (sql.Result, error) {
db, err := sql.Open(d.Driver, d.DataSource)
if err != nil {
return nil, err
}
defer db.Close()

return db.Exec(query, args)
}

func (d *DBConn) Query(query string, args ...interface{}) (*sql.Rows, error) {
db, err := sql.Open(d.Driver, d.DataSource)
if err != nil {
Expand Down

0 comments on commit a310661

Please sign in to comment.