Skip to content

Commit

Permalink
adapt readme
Browse files Browse the repository at this point in the history
  • Loading branch information
SbstnErhrdt authored Sep 3, 2021
1 parent a752510 commit 85379be
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Just set `SQL_TYPE` to either `MYSQL`, `POSTGRES`, `SQLITE` and you are good to
go get github.com/SbstnErhrdt/go-gorm-all-sql
```

In a development setting you can make use of the `env` package to load variables from a .env file into the ENV.

```shell
go get github.com/SbstnErhrdt/env
```

## Examples

```go
Expand All @@ -27,7 +33,10 @@ import (
)

func main() {
sql.ConnectToDatabase()
// load env
env.LoadEnvFiles() // reads the .env file in the working directory
// connect to DB
db, err := sql.ConnectToDatabase()
}
```

Expand All @@ -41,28 +50,31 @@ func main() {
Env variables

```
SQL_HOST=
SQL_USER=
SQL_PASSWORD=
SQL_PORT=
SQL_DATABASE=
SQL_TYPE=MYSQL
SQL_HOST=mysql.server.com
SQL_PORT=3306
SQL_USER=sql_user
SQL_PASSWORD=xxxxxx
SQL_DATABASE=test
```

## Postgres

```
SQL_HOST=
SQL_USER=
SQL_PASSWORD=
SQL_PORT=
SQL_DATABASE=
SQL_TYPE=POSTGRES
SQL_HOST=postgres.server.com
SQL_PORT=5432
SQL_USER=sql_user
SQL_PASSWORD=xxxxxx
SQL_DATABASE=test
SQL_SSL= // optional
```

## SQLite

```
SQL_DATABASE=
SQL_TYPE=SQLITE
SQL_DATABASE=data.db
```

## Logger
Expand All @@ -85,4 +97,4 @@ SQL_LOGGER=LOGRUS

```
docker-compose run --rm
```
```

0 comments on commit 85379be

Please sign in to comment.