Description Usage Arguments Value Note Author(s) See Also Examples
Executes an SQL query expecting an output through an "odb" connection.
1 2 |
odb |
An |
sqlQuery |
A single character value, containing an unique SQL query to be executed. |
stringsAsFactors |
Single logical value : should character columns in the output be turned to factor columns or not. |
check.names |
Single logical value : should column names in the output be made syntactically valid by |
encode |
Single logical value : should character values be translated from UTF-8 charset (native charset for ODB files) to the locale one or not. |
autoLogical |
Single logical value : should logical-like columns be converted to logical or not. Notice this is a workaround, the conversion is not properly done by JDBC and the logical column type is guessed from the values. |
Returns a data.frame, whose content depends on the SQL query executed.
To query databases built with OpenOffice or LibreOffice, it may be necessary to quote table and/or column names in sqlQuery
, as the default behavior of the HSQL engine is to convert unquoted table and column names to uppercases.
Sylvain Mareschal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # New empty .odb file
odbFile <- tempfile(fileext=".odb")
odb.create(odbFile, overwrite="do")
odb <- odb.open(odbFile)
# New table
SQL <- "CREATE TABLE fruits (
name VARCHAR(6) PRIMARY KEY,
color VARCHAR(32)
)"
odb.write(odb, SQL)
# Data insertion
dat <- data.frame(
c("banana", "pear", "peach"),
c("yellow", "yellow", "purple")
)
odb.insert(odb, "fruits", dat)
# Read content
print(odb.read(odb, "SELECT * FROM fruits"))
# Writes to the file and closes the connection
odb.close(odb, write=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.