easydb_connect | R Documentation |
Easily connect to a database. When connecting to a database for the first time, you will be prompted for connection details. Configuration details will be stored in the user-specified 'configuration file'. The next time you run the same command, config details will be automatically retreived from the config file. Any usernames and passwords are stored in your system credential manager (not on-disk)
easydb_connect(dbname, config_file, from_scratch = FALSE)
dbname |
name of database (string) |
config_file |
path to yaml file containing configuration information about databases (port, host, etc. ) (string) |
from_scratch |
should we delete any current config / credentials for databases with the supplied name and start again? (logical) |
connection to database (connection)
if(interactive()) { # Choose config file path # Do NOT use tempfile in practice. # Instead, choose a fixed location such as '~/.easydb' config <- tempfile('.example_config') # Initialise config file easydb_init(config) # Connect to SQLite database path_to_db <- system.file(package = 'easydb', 'testdbs/mtcars.sqlite') con <- easydb_connect(dbname = path_to_db, config_file = config) # Disconnect from database when finished easydb_disconnect(con) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.