Description Usage Arguments See Also Examples
Connect to a database using YAML configs
1 | db_connect(db, cache, ...)
|
db |
name of database, must be present in the file specified by |
cache |
optional caching of the connection. If set to |
... |
extra parameters passed to the database driver, even ones overriding the default values loaded from the YAML config |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
## create new connection
optbak <- options()
options('dbr.db_config_path' = system.file('example_db_config.yaml', package = 'dbr'))
con <- db_connect('sqlite')
str(con)
db_query('SELECT 42', 'sqlite')
## reusing the connection
str(db_connect('sqlite', cache = TRUE))
str(db_connect('sqlite'))
str(db_connect('sqlite'))
## kill cached connection
db_close(db_connect('sqlite', cache = FALSE))
## restore options
options(optbak)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.