TableSchemaList: Class '"TableSchemaList"'

Description Objects from the Class Slots Methods Author(s) Examples

Description

A list-based representation of a SQLite database which provides a general approach to loading data into a database as well as merging with the existing data.

Objects from the Class

Objects can be created by calls of the form new("TableSchemaList", tab.list, search.cols).

Slots

tab.list:

Object of class "list" A list of lists with each list representing a table and each element containing information on the definition of columns. There should be 6 elements to the list: db.cols a character vector containing the names of the columns db.schema a character vector of the same length as db.cols which contains the columns types (e.g. TEXT, INTEGER) db.constr a character string containing the statement at the end of a query indicating constraints dta.func a function which when applied to the input (usually a list) provides a data.frame to be inserted into the database. should.ignore a boolean value indicating whether duplicates implied by the constraints should be ignored upon insertion foreign.keys a list (or NULL) containing several elements named by each table to be joined. The two elements are local.keys which are the columns that should be kept from joining of the two tables and ext.keys which are the columns used in the joining.

search.cols:

Object of class "list" A list of lists defining labels and a dictionary for common searches. Each list should contain a name and have the following elements: table the table the column should be found in column the column to be searched against dict a named character vector in the form key=value where the key is a consistent label that can be database agnostic whereas the label is how that label translates to the current database.

Methods

createTable

signature(obj = "TableSchemaList"), table.name, mode=c("normal", "merge"): Produces a create table statement based on the table specified in table.name and whether the table should be temporary for merging purposes or normal permanent table

insertStatement

signature(obj = "TableSchemaList"), table.name, mode=c("normal", "merge"): Produces an insert statement based on the table specified in table.name and whether the table should be temporary for merging purposes or normal permanent table. This insert statement will be used in conjunction with dbGetPreparedQuery in the RSQLite package and the data.frame resulting from the dta.func function to populate the initial database table.

mergeStatement

signature(obj = "TableSchemaList"), table.name: Produces a statement joining an existing table and a temporary one and inserting into a new (non-temporary) tables

searchCols

signature(obj = "TableSchemaList"), name: Return the column(s) to be searched for a given search label

searchDict

signature(obj = "TableSchemaList"), name, value=NULL: Return the database values for a given search label and key

searchTables

signature(obj = "TableSchemaList"), name:Return the table name associated with a given search label

Author(s)

Daniel Bottomly

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
tbsl <- SangerTableSchemaList()

createTable(tbsl, table.name="reference", mode="normal")
createTable(tbsl, table.name="reference", mode="merge")

insertStatement(tbsl, table.name="reference", mode="normal")
insertStatement(tbsl, table.name="reference", mode="merge")

mergeStatement(tbsl, table.name="reference")

searchCols(tbsl)

searchDict(tbsl, "mapping.status", "unique")

searchTables(tbsl)

dbottomly/oligoMask documentation built on May 15, 2019, 1:22 a.m.