mysqlSupport {RMySQL} | R Documentation

## Support Functions

### Description

These functions are the workhorse behind the RMySQL package, but users need not invoke these directly. For details see `MySQL`.

### Usage

       ## MySQLDriver-related
       mysqlInitDriver(max.con=16, fetch.default.rec = 500, force.reload=FALSE)
       mysqlDriverInfo(obj, what, ...)
       mysqlDescribeDriver(obj, verbose = FALSE, ...)
       mysqlCloseDriver(drv, ...)

       ## MySQLConnection-related
       mysqlNewConnection(drv, dbname, username, password, host, unix.socket,
             port, client.flag, groups, default.file)
       mysqlCloneConnection(con, ...)
       mysqlConnectionInfo(obj, what, ...)
       mysqlDescribeConnection(obj, verbose = FALSE, ...)
       mysqlCloseConnection(con, ...)

       ## MySQLResult-related
       mysqlExecStatement(con, statement)
       mysqlFetch(res, n=0, ...)
       mysqlQuickSQL(con, statement)
       mysqlResultInfo(obj, what, ...)
       mysqlDescribeResult(obj, verbose = FALSE, ...)
       mysqlCloseResult(res, ...)
       mysqlDescribeFields(res, ...)

       ## data mappings, convenience functions, and extensions
       mysqlDataType(obj, ...)
       mysqlReadTable(con, name, row.names = "row_names", check.names = TRUE, ...)
       mysqlWriteTable(con, name, value, field.types, row.names = TRUE,
          overwrite=FALSE, append=FALSE, ..., allow.keywords = FALSE)
       mysqlImportFile(con, name, value, field.types, overwrite=FALSE,
          append=FALSE, header, row.names, nrows=50, sep=",", eol="\n",
          skip = 0, quote='"', ...)
       mysqlEscapeStrings(con, strings)

### Arguments

`max.con` | positive integer specifying maximum number of open connections. The current default of 10 is hardcoded in the C code.
`fetch.default.rec` | default number of rows to fetch (move to R/S-Plus). This default is used in `mysqlFetch`. The default is 500.
`force.reload` | logical indicating whether to re-initialize the driver. This may be useful if you want to change the defaults (e.g., `fetch.default.rec`). Note that the driver is a singleton (subsequent inits just returned the previously initialized driver, thus this argument).
`obj` | any of the MySQL DBI objects (e.g., `MySQLConnection`, `MySQLResult`).
`what` | character vector of metadata to extract, e.g., "version", "statement", "isSelect".
`verbose` | logical controlling how much information to display. Defaults to `FALSE`.
`drv` | an `MySQLDriver` object as produced by `mysqlInitDriver`.
`con` | an `MySQLConnection` object as produced by `mysqlNewConnection` and `mysqlCloneConnection`.
`res` | an `MySQLResult` object as produced by by `mysqlExecStatement`.
`username` | a character string with the MySQL's user name.
`password` | character string with the MySQL's password.
`groups` | character vector with one or more MySQL group names. For details see `MySQL`.
`default.file` | filename of an alternate MySQL options file.
`dbname` | character string with the MySQL database name.
`host` | character string with the name (or IP address) of the machine hosting the database. Default is `""`, which is interpreted as `localhost` by the MySQL's API.
`unix.socket` | (optional) character string with a filename for the socket file name. Consult the MySQL documentation for details.
`port` | (optional) positive integer specifying the TCP port number that the MySQL server is listening to. Consult the MySQL documentation for details.
`client.flag` | (optional) integer setting flags for the client. Consult the MySQL documentation for details.
`force` | logical indicating whether to close a connection that has open result sets. The default is `FALSE`.
`statement` | character string holding one (and only one) SQL statement.
`n` | number of rows to fetch from the given result set. A value of -1 indicates to retrieve all the rows. The default of 0 specifies to extract whatever the `fetch.default.rec` was specified during driver initialization `mysqlInit`.
`name` | character vector of names (table names, fields, keywords).
`value` | a data.frame.
`field.types` | a list specifying the mapping from R/S-Plus fields in the data.frame `value` to SQL data types. The default is `sapply(value,SQLDataType)`, see `MySQLSQLType`.
`header` | logical, does the input file have a header line? Default is the same heuristic used by `read.table`, i.e., TRUE if the first line has one fewer column that the second line.
`row.names` | a logical specifying whether to prepend the `value` data.frame row names or not. The default is `TRUE`.
`check.names` | a logical specifying whether to convert DBMS field names into legal S names. Default is `TRUE`.
`overwrite` | logical indicating whether to replace the table `name` with the contents of the data.frame `value`. The defauls is `FALSE`.
`append` | logical indicating whether to append `value` to the existing table `name`.
`nrows` | number of lines to rows to import using `read.table` from the input file to create the proper table definition. Default is 50.
`sep` | field separator character.
`eol` | end-of-line separator.
`skip` | number of lines to skip before reading data in the input file.
`quote` | the quote character used in the input file (defaults to `"`.
`allow.keywords` | logical indicating whether column names that happen to be MySQL keywords be used as column names in the resulting relation (table) being written. Defaults to `FALSE`, forcing `mysqlWriteTable` to modify column names to make them legal MySQL identifiers.
`strings` | a character vector of strings to be escaped
`...` | placeholder for future use.

### Value

`mysqlInitDriver` returns an `MySQLDriver` object.
`mysqlDriverInfo` returns a list of name-value metadata pairs.
`mysqlDescribeDriver` returns `NULL` (displays the object's metadata).
`mysqlCloseDriver` returns a logical indicating whether the operation succeeded or not.
`mysqlNewConnection` returns an `MySQLConnection` object.
`mysqlCloneConnection` returns an `MySQLConnection` object.
`mysqlConnectionInfo`returns a list of name-value metadata pairs.
`mysqlDescribeConnection` returns `NULL` (displays the object's metadata).
`mysqlCloseConnection` returns a logical indicating whether the operation succeeded or not.
`mysqlExecStatement` returns an `MySQLResult` object.
`mysqlFetch` returns a data.frame.
`mysqlQuickSQL` returns either a data.frame if the `statement` is a `select`-like or NULL otherwise.
`mysqlDescribeResult` returns `NULL` (displays the object's metadata).
`mysqlCloseResult` returns a logical indicating whether the operation succeeded or not.
`mysqlDescribeFields` returns a data.frame with one row per field with columns `name`, `Sclass`, `type`, `len`, `precision`, `scale`, and `nullOK` which fully describe each field in a result set. Except for `Sclass` (which shows the mapping of the field type into an R/S-Plus class) all the information pertains to MySQL's data storage attributes.
`mysqlReadTable` returns a data.frame with the contents of the DBMS table.
`mysqlWriteTable` returns a logical indicating whether the operation succeeded or not.
`mysqlDataType` retuns a character string with the closest
`mysqlResultInfo` returns a list of name-value metadata pairs.
`mysqlEscapeStrings` returns a character vector with each string escaped for MySQL special characters (such as single and double quotes). This is done using the character set used by the connection `con`.

### Constants

`.MySQLPkgName` (currently `"RMySQL"`), `.MySQLPkgVersion` (the R package version), `.MySQLPkgRCS` (the RCS revision), `.MySQL.NA.string` (character that MySQL uses to denote `NULL` on input), `.MySQLSQLKeywords` (a lot!) `.conflicts.OK`.

[Package RMySQL version 0.6-0 Index]