DB: Connection to a database

Description Usage Arguments Examples

Description

Returns a structure that helps you query and interact with your database.

Usage

1
2
DB(hostname = NA, port = NA, username = NA, password = NA,
  dbname = NA, filename = NA, dbtype = NA, profile = NA)

Arguments

hostname

the hostname for your database (i.e. dw.muppets.com)

port

the port for your database (i.e. 5432 or 3309)

username

the username for your database (i.e. kermit)

password

the password for your database (i.e. supersecret)

dbname

the dbname for your database (i.e. dw, production, staging)

filename

filepath to SQLite db

dbtype

the dbtype for your database (postgres, mysql, sqlite, or redshift)

profile

the profile for your database (a connection profile)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
db <- DemoDB()
db$query("select * from Artist;")
db$tables
db$tables$Artist
db$tables$Artist$head()
db$tables$Artist$all()
db$tables$Artist$sample()
db$query("select * from Artist;")
db$find_table("A*")
db$find_column("*Id*")
## Not run: 
db <-DB(username="kermit", password="rainbowconnection",
 hostname="localhost", dbname="muppetdb", dbtype="postgres")
db$save_credentails(profile="muppetdb")

db <-DB(profile="mysql_local")
db$query("select * from foo limit 10;")

## End(Not run)

yhat/db.r documentation built on May 4, 2019, 2:33 p.m.