writeToDB: Write The data.frame to MySQL Database

Description Usage Arguments Details Value

Description

Write the data.frame to MySQL database using the method that sent the query to the database server.

Usage

1
2
3
4
writeToDB(data, channel, table, quiet = TRUE, sql.out = FALSE,
  delete.first = FALSE, primary = 1L)

writeToSQL(data, sql.file, table, append = TRUE)

Arguments

data

the data.frame will be written to the database

channel

an ODBC channel object

table

the table name of database, which is used to organized query

quiet

logical, default is TRUE, show the progress bar

sql.out

logical, whether give the SQL message, just in case there are errors occur

delete.first

logical, whether to delete the records first using the primary key column

primary

integer, which column is the primary column, and just used when delete records

sql.file

the file name of the output sql file

append

pass to the write.table function, whether overwrite the existed file or appent to it

Details

The function can delete the records before writing to the database, however if it can be make sure that the there is no duplicated records, the deletion can be skipped, saving time. The deletion work is based on the primary key, so the column index has to be given, and the column name should the same as that in the database.

The mechanism of the function is to paste an INSERT query and send to the database server. Sum method seems safe to be executed.

The function writeToSQL just save the query to the .sql file, which can be used to import to the database manually, however, this is a good choice for the big data set.

Value

Besides errors messages, no return.


baixueyuan/zsl documentation built on May 11, 2019, 5:27 p.m.