Skip to content

Commit

Permalink
added mysql package
Browse files Browse the repository at this point in the history
  • Loading branch information
DESKTOP-LKF81KV\Mak Moinee committed Oct 21, 2022
1 parent 61309e2 commit bbf5042
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/MakMoinee/go-mith

go 1.18
go 1.19

require (
github.com/go-chi/chi v1.5.4
Expand Down
34 changes: 34 additions & 0 deletions pkg/mysql/mysql.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package mysql

import (
"database/sql"
"log"
)

type service struct {
DatabaseName string
DatabaseServer string
DatabaseUser string
DatabasePassword string
ConnectionString string
Db *sql.DB
DbDriver string
}

type GoMithMysql interface {
GetDBConnection() *sql.DB
}

func NewGoMithMysql(dbName, dbServer, dbUser, dbPassword, dbDriver string) GoMithMysql {
svc := service{}

return &svc
}

func (s *service) GetDBConnection() *sql.DB {
db, err := sql.Open(s.DbDriver, s.ConnectionString)
if err != nil {
log.Println(err.Error())
}
return db
}

0 comments on commit bbf5042

Please sign in to comment.