Description Usage Arguments Value Examples
These functions standardlise various database connection methods and use a fairly uniform way to create connection objects which can then be used in subsequent SQL queries.
1 2 3 | xlConnPostgres(u, pw, db, server, port, ...)
xlConnSQLServ(u = NULL, pw = NULL, db, server, instance, trusted = T, ...)
|
u |
Username of the database credentials. |
pw |
Password of the database credentials. |
db |
The name of the database. |
server |
The server name or host name (in the case of AWS RedShift). |
port |
The port for the database. |
... |
Any additional arguments passed to respective function. |
instance |
The instance of the connection, suitable for a SQL Server. |
trusted |
Logical input, instructing the connection to use the operating
system's credientials if |
xlConnPostgres
returns a postgres source object src
from
src_postgres
, to be used in table references like this one:
tbl(src, sql('<sql_query>'))
.
xlConnSQLServ
passes arguments to odbcDriverConnect
,
which returns the RODBC
object conn
to be used in a function such as
sqlQuery(cnn, '<sql_query>')
.
1 2 3 4 5 6 7 8 9 10 11 12 | ## Not run:
src <- xlConnPostgres(u, pw, db, server, port)
sample_table <- tbl(src, sql('select top 100 * from table1'))
## End(Not run)
## Not run:
conn <- xlConnSQLServ(db, server, instance)
sqlQuery(conn, 'select * from information_schema.tables')
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.