Establishes a connection to the database

connect(
  database = NULL,
  host = "localhost",
  port = 5432,
  username = NULL,
  password = NULL,
  sqlite_file = NULL
)

Arguments

database

target db

host

db host: typically "localhost"

port

db port number

username

db username

password

db password

sqlite_file

filename as character vector if using an sqlite db (in which case this is the only argument that needs to be supplied)

Value

a database object connection

Examples

db_pth <- system.file("testdata/synthetic_db.sqlite3", package = "inspectEHR") ctn <- connect(sqlite_file = db_pth) class(ctn)
#> [1] "SQLiteConnection" #> attr(,"package") #> [1] "RSQLite"
DBI::dbDisconnect(ctn)