odb.export: Exports an ODB database to a SQL file.

Description Usage Arguments Value Note Author(s) Examples

View source: R/odb.export.r

Description

Produces SQL queries describing the structure of the database and its content, and saves it to a file.

Usage

1

Arguments

odb

An ODB object, as produced by odb.open.

file

Path to the file in which export the SQL queries.

Value

Invisibly returns TRUE if succeeds, raises an error if not.

Note

It is just a wrapper for the "SCRIPT '[file]'" SQL query, as implemented in HSQLDB.

Column comments and queries won't be exported, as they are not stored in the HSQL database.

Author(s)

Sylvain Mareschal

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  # New empty .odb file
  odbFile <- tempfile(fileext=".odb")
  odb.create(odbFile, overwrite="do")
  odb <- odb.open(odbFile)
  
  # New table
  odb.write(odb, "CREATE TABLE fruits (name VARCHAR(6) PRIMARY KEY)")
  odb.insert(odb, "fruits", c("banana", "pear", "peach"))
  
  # Export to a file
  sqlFile <- tempfile(fileext=".odb")
  odb.export(odb, sqlFile)
  
  # Writes to the file and closes the connection
  odb.close(odb, write=TRUE)

Example output

Loading required package: DBI
Loading required package: RJDBC
Loading required package: rJava
Execution : 1/1 (ETA: 00:00:00)
Execution : 1/3 (ETA: 00:00:00.014)2/3 (ETA: 00:00:00.009)3/3 (ETA: 00:00:00)
Execution : 1/1 (ETA: 00:00:00)

ODB documentation built on March 26, 2020, 7:46 p.m.