db.q | R Documentation |
This function sends SQL queries into the connected database to execute, and then extracts the result if there is any.
db(..., nrows = 100, conn.id = 1, sep = " ", verbose = TRUE)
.db(..., nrows = 100, conn.id = 1, sep = " ", verbose = TRUE)
db.q(..., nrows = 100, conn.id = 1, sep = " ", verbose = TRUE)
... |
One or multiple SQL query strings. Multiple strings will be concatenated into one SQL query string. |
nrows |
An integer, default is 100. How many rows should be extracted? If it is |
conn.id |
An integer, default is 1. The ID of the connection. See |
sep |
A string, default is a space character |
verbose |
A logical, default is |
A data.frame
that contains the result if the result is not empty. Otherwise, it returns a logical value, which indicates whether the SQL query has been sent to the database successfully.
Author: Predictive Analytics Team at Pivotal Inc.
Maintainer: Frank McQuillan, Pivotal Inc. fmcquillan@pivotal.io
db.connect
, db.objects
, db.list
,
## Not run:
## set up the database connection
## Assume that .port is port number and .dbname is the database name
cid <- db.connect(port = .port, dbname = .dbname, verbose = FALSE)
db("show search_path", conn.id = cid)
.db("drop table if exists tr;",
"create temp table tr (idx integer,
val double precision);",
"insert into tr values (1, 2.3), (2, 3.4)", conn.id = cid)
db.q("select * from tr", conn.id = cid)
db.disconnect(cid, verbose = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.