Description Usage Arguments Details Value See Also Examples
Methods for inserting, querying and deleting
OPMX
objects into or from
(SQL-based) relational databases. A common
database scheme is assumed as defined in the auxiliary
SQL files of this package (run
opm_files
in "sql"
mode), but tables
could be named differently, and columns could be added
containing user-defined combinations of metadata.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ## S4 method for signature 'ANY'
opm_dbcheck(conn, metadata = NULL,
time.points = TRUE, wells = TRUE)
## S4 method for signature 'MOPMX'
opm_dbclass(object)
## S4 method for signature 'OPM'
opm_dbclass(object)
## S4 method for signature 'OPMS'
opm_dbclass(object)
## S4 method for signature 'integer'
opm_dbclass(object)
## S4 method for signature 'character,ANY'
opm_dbclear(object, conn, map.tables = NULL, klass = "OPM_DB")
## S4 method for signature 'integer,DBIConnection'
opm_dbclear(object, conn, map.tables = NULL, klass = "OPM_DB")
## S4 method for signature 'character,DBIConnection'
opm_dbfind(object, conn, map.tables = NULL, klass = "OPM_DB")
## S4 method for signature 'character,ANY'
opm_dbget(object, conn,
map.tables = NULL, include = 2L, klass = c(opm_dbclass(include), "MOPMX"))
## S4 method for signature 'integer,DBIConnection'
opm_dbget(object, conn,
map.tables = NULL, include = 2L, klass = c(opm_dbclass(include), "MOPMX"))
## S4 method for signature 'ANY,ANY'
opm_dbnext(object, conn, map.tables = NULL)
## S4 method for signature 'DBTABLES,DBIConnection'
opm_dbnext(object, conn, map.tables = NULL)
## S4 method for signature 'ANY,ANY'
opm_dbput(object, conn, ...)
## S4 method for signature 'DBTABLES,DBIConnection'
opm_dbput(object, conn,
map.tables = NULL, start = opm_dbnext(object, conn, map.tables))
|
object |
|
conn |
Database connection object. Currently only
For using |
map.tables |
Passed as |
klass |
Character vector indicating one or several class names. For PM data this argument should not be changed. |
include |
Integer scalar indicating whether
aggregated data (1) or aggregated and discretised data
(2) or neither (0) should be added to the result. The
numeric method of |
start |
Integer vector determining the minimum
primary keys to which those in |
metadata |
Empty or data frame with metadata to be
added to the check object |
time.points |
Index of one to several time points. Selection speeds up database I/O during checking. |
wells |
Index of one to several wells. Selection speeds up database I/O during checking. |
... |
Optional arguments passed between the methods. |
The DBIConnection
methods send table and column
names are through make.db.names
from the DBI
package or its dependencies before including them into
SQL queries, if any. As dictated by by
from the pkgutils packages, this is done after
applying map.tables
.
opm_dbcheck
attempts to insert, query and delete
the first two plates from the object vaas_4
into
the database. If everything is correctly set up, this
should work without error unless these two
plates from vaas_4
have already been inserted. If
errors occur, it is up to the user to clean up the data
base (as far as necessary).
Note that the deletion mechanism is based on ON
DELETE CASCADE
. To enable this in SQLite
,
PRAGMA foreign_keys = ON;
has to be called each
time a database is opened. See the according demo
entry.
The main functions are those for create, search, read and delete operations:
opm_dbput
returns an integer vector containing the primary keys of
the inserted plates.
opm_dbfind
returns an
integer vector containing the primary keys of the found
plates.
opm_dbget
returns a
MOPMX
object with one element per plate
type.
opm_dbclear
invisibly returns the
result of dbGetQuery
(which is usually
NULL
).
Regarding the helper functions,
opm_dbnext
returns an integer scalar that is
suitable as start
argument of opm_dbput
,
whereas opm_dbclass
returns a character scalar
with the name of the intermediary class (derived from
OPM_DB
) to be created for database I/O.
These need not normally be called by an opm user.
For checking whether a database (connection) is correctly
set up, opm_dbcheck
is available, which returns a
character vector whose elements are either ok or a
description of the error that has occurred at that step
of the checking process.
DBI::make.db.names pkgutils::by
1 2 3 4 5 6 7 8 | # The SQL files for generating the expected database tables. Tables can
# be renamed, but then an according 'map.tables' argument must be used.
opm_files("sql")
# Usage examples are given in these demos. An according database must be
# made accessible beforehand.
if (interactive())
demo(package = "opm")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.