first commit
This commit is contained in:
commit
07393f57d3
10 changed files with 194 additions and 0 deletions
33
Database/main.go
Normal file
33
Database/main.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package Database
|
||||
|
||||
import (
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DbHandlerType struct {
|
||||
Sqlx *sqlx.DB
|
||||
}
|
||||
|
||||
var DbHandler *DbHandlerType
|
||||
|
||||
func (database *DbHandlerType) ConnectToDb() {
|
||||
DbHandler := &DbHandlerType{}
|
||||
db, err := sqlx.Connect("mysql", "user:Sml12345@(10.0.1.5:3306)/karma")
|
||||
DbHandler.Sqlx = db
|
||||
DbHandler.Sqlx.SetConnMaxLifetime(time.Minute * 5)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
for i := range schema {
|
||||
DbHandler.Sqlx.MustExec(schema[i])
|
||||
}
|
||||
}
|
||||
func (database *DbHandlerType) AddPoint(uid int, cid int) {
|
||||
|
||||
}
|
||||
func (database *DbHandlerType) GetPoints(uid int, cid int) {
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue