Skip to content

Commit

Permalink
CHG Renaming Env-Vars
Browse files Browse the repository at this point in the history
  • Loading branch information
fbury-hec committed Mar 5, 2024
1 parent ff023fa commit 075b8f7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

## Database-Connection
### SQLITE
- PROVIDER = sqlite
- CON_STR = path to file (data.db)
- DB_PROVIDER = sqlite
- DB_CONNSTR = path to file (data.db)

### MySQL
- PROVIDER = mysql
- CON_STR = root:my-secret-pw@tcp(127.0.0.1:3306)/meadows
- DB_PROVIDER = mysql
- DB_CONNSTR = root:my-secret-pw@tcp(127.0.0.1:3306)/meadows


## File-Storage
Expand Down
2 changes: 1 addition & 1 deletion internal/data_store/mysql/dbHistory.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func updateDb() {
log.Fatalln(err.Error())
}
} else {
db, err = sqlx.Connect("mysql", os.Getenv("CON_STR")+"meadow")
db, err = sqlx.Connect("mysql", os.Getenv("DB_CONNSTR")+"meadow")
if err != nil {
log.Fatalln(err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/data_store/mysql/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ func (m stor) GetType() string {

func init() {

if os.Getenv("PROVIDER") != "mysql" {
log.New().Info("Skip mysql Init by Config: " + os.Getenv("PROVIDER"))
if os.Getenv("DB_PROVIDER") != "mysql" {
log.New().Info("Skip mysql Init by Config: " + os.Getenv("DB_PROVIDER"))
Connection.ConnectionError = errors.New("mysql disabled")
return
}

var err error

db, err = sqlx.Connect("mysql", os.Getenv("CON_STR"))
db, err = sqlx.Connect("mysql", os.Getenv("DB_CONNSTR"))
if err != nil {
log.Fatalln(err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/data_store/sqlite/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ func (m stor) GetType() string {

func init() {

if os.Getenv("PROVIDER") != "sqlite" {
log.New().Info("Skip sqlite Init by Config: " + os.Getenv("PROVIDER"))
if os.Getenv("DB_PROVIDER") != "sqlite" {
log.New().Info("Skip sqlite Init by Config: " + os.Getenv("DB_PROVIDER"))
Connection.ConnectionError = errors.New("sqlite disabled")
return
}

var err error

db, err = sqlx.Connect("sqlite3", os.Getenv("CON_STR"))
db, err = sqlx.Connect("sqlite3", os.Getenv("DB_CONNSTR"))
if err != nil {
log.Fatalln(err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/data_store/storageHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func GetProvider() (*Storage, error) {
var result Storage

dbProvider := os.Getenv("PROVIDER")
dbProvider := os.Getenv("DB_PROVIDER")

if dbProvider == "sqlite" {
result = &sqlite.Connection
Expand Down

0 comments on commit 075b8f7

Please sign in to comment.