import_data: Import Data

View source: R/import_data.R

import_dataR Documentation

Import Data

Description

Function to import data from the local MariaDB database. This assumes that your username and password are available as the environment variables DB_USERNAME and DB_PASSWORD. rofi uses the package dotenv to access environment variables and load any .env file in the project directory. We therefore recommed storing the username and password in an .env file in the project directory, but make sure this file is ignored by git so that you don't put it in version control by mistake. All this is taken care of by using rofi::init().

Usage

import_data(
  user = NULL,
  password = NULL,
  db.name = "opportunities_for_improvement",
  table.names = c("swetrau", "swetrau.20210602.20230228", "atgarder",
    "atgarder.20210602.20230228", "problem", "fmp", "fmp.20210602.20230228",
    "kvalgranskning2014.2017"),
  ignore.missing.table = TRUE,
  env.file = ".env",
  ask = TRUE,
  test = FALSE,
  silent = FALSE
)

Arguments

user

Character or NULL. The default is NULL in which case the username is read from the corresponding environment variable called DB_USERNAME, using Sys.getenv("DB_USERNAME").

password

Character. The default is NULL in which case the password is read from the corresponding environment variable called DB_PASSWORD, using Sys.getenv("DB_PASSWORD").

db.name

Character. The name of the database. Defaults to "opportunities_for_improvement".

table.names

Character. The name(s) of the table(s) in the database. Defaults to c("swetrau", "fmp", "atgarder", "problem", "kvalgranskning2014.2017").

ignore.missing.table

Logical. If TRUE the function will continue even if a table with the name specified in table.names does not exist in the database. Defaults to TRUE.

env.file

Character. The name of the file defining the environment variables used to connect to the database. Defaults to ".env".

ask

Logical. If TRUE you will be prompted to enter your user name and password to access the database, if these are not available as environment variables. Defaults to TRUE.

test

Logical. If TRUE the test, also called scrambled, version of the data will be imported. Defaults to FALSE.

silent

Logical. If FALSE a message is displayed with the names of the imported datasets. Defaults to FALSE.

Value

A list of data.frames.


martingerdin/rofi documentation built on Dec. 3, 2024, 12:10 a.m.