Learn R Programming

ODB (version 1.2.1)

odb.create: Creates a .odb empty file.

Description

Creates an empty HSQL database embedded in a .odb file, copying a template.

Usage

odb.create(odbFile, template = NULL,
    overwrite = c("warning", "do", "skip", "stop"))

Arguments

odbFile

Path to the new file.

template

Template to copy. You should not have to care about it, as the current version is included in the package (used if NULL).

overwrite

Single character value, defining how to handle overwriting : 'warning' will overwrite and raise a warning if a file is replaced, 'stop' will raise an error before copying anything, 'do' will overwrite silently, 'skip' won't silently.

Value

Invisibly returns the single logical value returned by file.copy, if no critical error occurs before it is called.

Examples

Run this code
# NOT RUN {
  # New empty .odb file
  odbFile <- tempfile(fileext=".odb")
  odb.create(odbFile, overwrite="do")
  odb <- odb.open(odbFile)
  
  # Empty template
  print(odb.tables(odb))
  
  # New table
  odb.write(odb, "CREATE TABLE fruits (name VARCHAR(6) PRIMARY KEY)")
  odb.insert(odb, "fruits", c("banana", "pear", "peach"))
  
  # Writes to the file and closes the connection
  odb.close(odb, write=TRUE)
  
  
  # Use as template
  odbFile2 <- tempfile(fileext=".odb")
  odb.create(odbFile2, template=odbFile, overwrite="do")
  odb <- odb.open(odbFile2)
  print(odb.tables(odb))
  odb.close(odb, write=TRUE)
# }

Run the code above in your browser using DataLab