# NOT RUN {
# New empty .odb file
odbFile <- tempfile(fileext=".odb")
odb.create(odbFile, overwrite="do")
odb <- odb.open(odbFile)
# New table
SQL <- "CREATE TABLE fruits (
name VARCHAR(6) PRIMARY KEY,
color VARCHAR(32)
)"
odb.write(odb, SQL)
# Data insertion
dat <- data.frame(
c("banana", "pear", "peach"),
c("yellow", "yellow", "purple")
)
odb.insert(odb, "fruits", dat)
# Read content
print(odb.read(odb, "SELECT * FROM fruits"))
# Writes to the file and closes the connection
odb.close(odb, write=TRUE)
# }
Run the code above in your browser using DataLab