1
0
mirror of https://github.com/JustKato/FreePad.git synced 2026-02-24 00:00:46 +02:00

+ Database insertion/overwriting

+ Helper
This commit is contained in:
2022-05-15 15:59:30 +03:00
parent e508d753ce
commit 0d71bf3650
5 changed files with 45 additions and 10 deletions

View File

@@ -9,7 +9,7 @@ import (
_ "github.com/go-sql-driver/mysql"
)
func GetConn() *sql.DB {
func GetConn() (*sql.DB, error) {
user := os.Getenv("MYSQL_USER")
password := os.Getenv("MYSQL_PASSWORD")
@@ -18,7 +18,7 @@ func GetConn() *sql.DB {
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@/%s", user, password, dbname))
if err != nil {
panic(err)
return nil, err
}
// Set options
@@ -26,5 +26,5 @@ func GetConn() *sql.DB {
db.SetMaxOpenConns(10)
db.SetMaxIdleConns(10)
return db
return db, nil
}