Skip to content

Commit

Permalink
docs: uses user from envvars
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Jul 7, 2024
1 parent d80f0a8 commit e07567d
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions vignettes/databases.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ Below you find chunks to create a data storage object for each supported databas

### PostgreSQL

```r
Sys.setenv("TELEMTRY_PASS" = "mysecretpassword")
```{r, eval=FALSE}
Sys.setenv("POSTGRES_USER" = "postgres", "POSTGRES_PASS" = "mysecretpassword")
data_storage <- DataStoragePostgreSQL$new(
user = "postgres",
password = Sys.getenv("TELEMTRY_PASS"),
user = Sys.getenv("POSTGRES_USER"),
password = Sys.getenv("POSTGRES_PASS"),
hostname = "127.0.0.1",
port = 5432,
dbname = "shiny_telemetry",
Expand All @@ -65,13 +65,16 @@ _notes_:
- Never store passwords and other sensitive directly in code. Please use environment variables or other secure methods;
- The `.Renviron` file is the default way in R of setting up environment variables _(instead of `Sys.setenv()` as shown above for convenience)_.

To run PostgreSQL in a container locally, you can use the following Docker compose file: [`inst/examples/postgresql/docker-compose.yml`](https://github.com/Appsilon/shiny.telemetry/tree/main/inst/examples/postgresql/docker-compose.yml).


### MariaDB / MySQL

```r
Sys.setenv("TELEMTRY_PASS" = "mysecretpassword")
```{r, eval=FALSE}
Sys.setenv("MARIADB_USER" = "mariadb", "MARIADB_PASS" = "mysecretpassword")
data_storage <- DataStorageMariaDB$new(
user = "mariadb",
password = Sys.getenv("TELEMTRY_PASS"),
user = Sys.getenv("MARIADB_USER"),
password = Sys.getenv("MARIADB_PASS"),
hostname = "127.0.0.1",
port = 3306,
dbname = "shiny_telemetry"
Expand All @@ -81,22 +84,23 @@ data_storage <- DataStorageMariaDB$new(
_notes_:

- The `dbname` database needs to be created before running the application with `{shiny.telemetry}`;
- Never store passwords and other sensitive directly in code. Please use environment variables or other secure methods;
- Never store usernames, passwords and other sensitive directly in code. Please use environment variables or other secure methods;
- The `.Renviron` file is the default way in R of setting up environment variables _(instead of `Sys.setenv()` as shown above for convenience)_.

### MS SQL Server
To run MariaDB in a container locally, you can use the following Docker compose file: [`inst/examples/mariadb/docker-compose.yml`](https://github.com/Appsilon/shiny.telemetry/tree/main/inst/examples/mariadb/docker-compose.yml).

### MS SQL Server

```r
Sys.setenv("TELEMTRY_PASS" = "mysecretpassword")
```{r, eval=FALSE}
Sys.setenv(MSSQL_USER = "sa", MSSQL_PASS = "my-Secr3t_Password")
data_storage <- DataStorageMSSQLServer$new(
user = "sqlserver",
password = Sys.getenv("TELEMTRY_PASS"),
hostname = "servername",
user = Sys.getenv("MSSQL_USER"),
password = Sys.getenv("MSSQL_PASS"),
hostname = "127.0.0.1",
port = 1433,
dbname = "my_db",
driver = "ODBC Driver 17 for SQL Server",
trust_server_certificate = "NO"
driver = "ODBC Driver 18 for SQL Server",
trust_server_certificate = "YES"
)
```

Expand All @@ -106,28 +110,32 @@ _notes_:
- Never store passwords and other sensitive directly in code. Please use environment variables or other secure methods;
- The `.Renviron` file is the default way in R of setting up environment variables _(instead of `Sys.setenv()` as shown above for convenience)_.

To run Microsoft SQL Server in a container locally, you can use the following Docker compose file: [`inst/examples/mssql/docker-compose.yml`](https://github.com/Appsilon/shiny.telemetry/tree/main/inst/examples/mssql/docker-compose.yml).

### MongoDB

```r
```{r, eval=FALSE}
data_storage <- DataStorageMongoDB$new(
host = "localhost",
dbname = "test",
authdb = NULL,
options = NULL,
ssl_options = mongolite::ssl_options()
)
To run MongoDB in a container locally, you can use the following Docker compose file: [`inst/examples/mssql/docker-compose.yml`](https://github.com/Appsilon/shiny.telemetry/tree/main/inst/examples/mongodb/docker-compose.yml).
```

### SQLite

Unlike the other database backends, SQLite only requires a path to a file that the Shiny application can write to.

```r
```{r, eval=FALSE}
data_storage <- DataStorageSQLite$new(
db_path = "telemetry.sqlite"
)
```

Unlike the other database backends, SQLite only requires a path to a file that the Shiny application can write to.

## Data storage usage in `{shiny.telemetry}`

The data storage API to read and write events for `{shiny.telemetry}` is consistent across all backends, which allows the developer to implement and test the package with the most convenient backend and then easily migrate to an external database.
Expand Down

0 comments on commit e07567d

Please sign in to comment.