Description Usage Arguments Details Value Examples
View source: R/makeSQLDataFrame.R
Given a file name, makeSQLDataFrame
will write
the file contents into SQL database, and open the database
table as SQLDataFrame.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
filename |
A |
dbtable |
A character string for the to be saved database
table name. If not provided, will use the name of the input
|
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. |
conn |
a valid |
host |
host name for SQL database. |
user |
user name for SQL database. |
dbname |
database name for SQL connection. For SQLite
connection, it uses a |
password |
password for SQL database connection. |
type |
The SQL database type, supports "SQLite" and "MySQL". |
overwrite |
Whether to overwrite the |
sep |
a character string to separate the terms. Not
‘NA_character_’. Default is |
index |
Whether to create an index table. Default is FALSE. |
... |
additional arguments to be passed. |
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.)
A SQLDataFrame
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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, quote = FALSE)
obj <- makeSQLDataFrame(filename, dbkey = "rowname")
obj
## save as MySQL database
## Not run:
localConn <- DBI::dbConnect(dbDriver("MySQL"),
host = "",
user = "",
password = "",
dbname = "")
makeSQLDataFrame(filename, dbtable = "mtcMysql", dbkey = "rowname", conn = localConn)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.