makeSQLDataFrame: Construct SQLDataFrame from file.

Description Usage Arguments Details Examples

Description

Given a file name, makeSQLDataFrame will write the file contents into SQLite database, and open the database table as SQLDataFrame.

Usage

1
2
makeSQLDataFrame(filename, dbkey = character(), dbname = NULL,
  dbtable = NULL, overwrite = FALSE, sep = ",", index = TRUE, ...)

Arguments

filename

A data.frame or DataFrame object, or a character string of the filepath to the text file that to be saved as SQL database table.

dbkey

A character vector of column name(s) that could uniquely identify each row of the filename. Must be provided in order to construct a SQLDataFrame.

dbname

A character string of the filepath of to-be-saved database file. If not provided, will use a tempfile(fileext = ".db").

dbtable

A character string for the to be saved database table name. If not provided, will use the name of the input data.frame or DataFrame object, or the basename(filename) without extension if filename is a character string.

overwrite

Whether to overwrite the dbtable if already exists. Default is FALSE.

sep

a character string to separate the terms. Not ‘NA_character_’. Default is ,.

Details

The provided file must has one or more columns to unique identify each row (no duplicate rows allowed). The file must be rectangular without rownames. (if rownames are needed, save it as a column.)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
mtc <- tibble::rownames_to_column(mtcars)

## data.frame input
obj <- makeSQLDataFrame(mtc, dbkey = "rowname")
obj

## character input
filename <- file.path(tempdir(), "mtc.csv")
write.csv(mtc, file= filename, row.names = FALSE)
obj <- makeSQLDataFrame(filename, dbkey = "rowname")
obj

Liubuntu/SQLDataFrame documentation built on May 17, 2019, 7:43 a.m.