getInsertSQL {xml2relational}R Documentation

Exporting the relational data model and data to a database

Description

Produces ready-to-run SQL INSERT statements to import the data transformed with toRelational() into a SQL database.

Usage

getInsertSQL(
  ldf,
  table.name,
  line.break = "\n",
  one.statement = FALSE,
  tz = "UTC"
)

Arguments

ldf

A list of dataframes created by toRelational() (the data tables transformed from XML to a relational schema).

table.name

Name of the table from the data table list ldf for which INSERT statements are to be created.

line.break

Line break character that is added to the end of each INSERT statement (apart from the semicolon that is added automatically). Default is "\n".

one.statement

Determines whether all INSERT statements will be returned as one piece of SQL code (one.statement = TRUE) or if each INSERT statement will be stored in a separate element of the return vector. In the former case the return vector will have just one element, in the latter case as many elements as there are data records to insert. Default is FALSE (return vector has one element per INSERT statement.

tz

The code of the timezone used for exporting timestamp data. Default it "UTC" (Coordinated Universal Time).

Value

A character vector with exactly one element (if argument one.statement = TRUE) or with one element per INSERT statement.

See Also

Other xml2relational: getCreateSQL(), savetofiles(), toRelational()

Examples

# Find path to custmers.xml example file in package directory
path <- system.file("", "customers.xml", package = "xml2relational")
db <- toRelational(path)

sql.code <- getInsertSQL(db, "address")


[Package xml2relational version 0.1.1 Index]