
Last chance! 50% off unlimited learning
Sale ends in
dbManager(obj, ...)
dbManager
and
dbObjectId
in a database-specific manner.
For instance dbManager("Oracle")
produces
an object of class OraManager
and
is equivalent to using Oracle
.
Similarly dbManager("Oracle")
produces
an OraManager
object and its equivalent
to invoking Oracle
.This object is required to create connections to one or several database engines.
dbConnect
.On connections, SQL statements and resultSets:
dbExecStatement
dbExec
fetch
quickSQL
On transaction management:
On meta-data:
describe
getVersion
getDatabases
getTables
getFields
getCurrentDatabase
getTableIndices
getException
getStatement
hasCompleted
getRowCount
getAffectedRows
getNullOk
getInfo
# create a Oracle instance and create one connection.
> m <- dbManager("Oracle")
> m
OraManager id = (7269)
# open the connection using user, passsword, etc., as
# specified in the file \file{\$HOME/.my.cnf}
> con <- dbConnect(m)
# Let's look at the status of the manager
> describe(m, verbose = F)
OraManager id = (7269)
Max connections: 16
Conn. processed: 1
Default records per fetch: 500
Open connections: 1
# Run an SQL statement by creating first a resultSet object
> rs <- dbExecStatement(con,
statement = "SELECT w.laser_id, w.wavelength, p.cut_off
FROM WL w, PURGE P
WHERE w.laser_id = p.laser_id
SORT BY w.laser_id")
> rs
OraResultSet id = (12629,1,3)
# we now fetch records from the restulSet into a data.frame
> data <- fetch(rs, n = -1) # extract all rows
> dim(data)
[1] 1779 18
# Extract meta-data information. What Ora databases are there
# available on host "wyner"
> getDatabases(m, host = "wyner")
Database
1 mysql
2 opto
3 test
4 iptraffic
5 fraud
> # What tables are there in the "opto" database?
> dbTables(m, dbname = "opto", host = "wyner")
Tables in opto
1 PBCT
2 PURGE
3 WL
4 liv25
5 liv85
Run the code above in your browser using DataLab