These functions are the workhorse behind the RPostgreSQL package, but
users need not invoke these directly. For details see PostgreSQL
.
## PostgreSQLDriver-related
postgresqlInitDriver(max.con=16, fetch.default.rec = 500, force.reload=FALSE)
postgresqlDriverInfo(obj, what, ...)
postgresqlDescribeDriver(obj, verbose = FALSE, ...)
postgresqlCloseDriver(drv, ...) ## PostgreSQLConnection-related
postgresqlNewConnection(drv, user, password, host, dbname, port,
tty, options, forceISOdate = TRUE)
postgresqlCloneConnection(con, ...)
postgresqlConnectionInfo(obj, what, ...)
postgresqlDescribeConnection(obj, verbose = FALSE, ...)
postgresqlCloseConnection(con, ...)
## PostgreSQLResult-related
postgresqlExecStatement(con, statement, params, ...)
postgresqlFetch(res, n=0, ...)
postgresqlQuickSQL(con, statement, ...)
postgresqlResultInfo(obj, what, ...)
postgresqlDescribeResult(obj, verbose = FALSE, ...)
postgresqlCloseResult(res, ...)
postgresqlDescribeFields(res, ...)
## data mappings, convenience functions, and extensions
postgresqlDataType(obj, ...)
postgresqlReadTable(con, name, row.names = "row.names", check.names = TRUE, ...)
postgresqlWriteTable(con, name, value, field.types, row.names = TRUE,
overwrite=FALSE, append=FALSE, ..., allow.keywords = FALSE)
postgresqlpqExec(con, statement)
postgresqlCopyIn(con, filename)
postgresqlgetResult(con)
postgresqlEscapeStrings(con, preescapedstring)
postgresqlEscapeBytea(con, raw_data)
postgresqlUnescapeBytea(escapedbytea)
postgresqlQuoteId(identifiers)
postgresqlTableRef(identifiers)
postgresqlImportFile(con, name, value, field.types, overwrite=FALSE,
append=FALSE, header, row.names, nrows=50, sep=",", eol="\n",
skip = 0, quote="\"", ...)
## Transaction Management
postgresqlTransactionStatement(con, statement)
postgresqlInitDriver
returns an PostgreSQLDriver
object.
postgresqlDriverInfo
returns a list of name-value metadata pairs.
postgresqlDescribeDriver
returns NULL
(displays the object's
metadata).
postgresqlCloseDriver
returns a logical indicating whether the
operation succeeded or not.
postgresqlNewConnection
returns an PostgreSQLConnection
object.
postgresqlCloneConnection
returns an PostgreSQLConnection
object.
postgresqlConnectionInfo
returns a list of name-value metadata pairs.
postgresqlDescribeConnection
returns NULL
(displays the
object's metadata).
postgresqlCloseConnection
returns a logical indicating whether the
operation succeeded or not.
postgresqlExecStatement
returns an PostgreSQLResult
object.
postgresqlFetch
returns a data.frame.
postgresqlQuickSQL
returns either a data.frame if the statement
is
a select
-like or NULL otherwise.
postgresqlDescribeResult
returns NULL
(displays the object's
metadata).
postgresqlCloseResult
returns a logical indicating whether the
operation succeeded or not.
postgresqlDescribeFields
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 PostgreSQL's data storage attributes.
postgresqlReadTable
returns a data.frame with the contents of the
DBMS table.
postgresqlWriteTable
returns a logical indicating whether the
operation succeeded or not.
postgresqlpqExec
returns NUL
(executes the statement
but does not try to get result. This is called internally
from postgresqlWriteTable
before postgresqlCopyInDataframe
postgresqlCopyIn
returns NULL
(copies the content
of the file through the socket connection to postgresql backend.
This should be used just after COPY tablename FROM STDIN query. This is not used now.)
postgresqlCopyInDataframe
returns NULL
(copies the content
of the dataframe through the socket connection to postgresql backend.
Strings are encoded as UTF-8 for transfer. The client_encoding should be set to UTF-8.
This should be used just after COPY tablename FROM STDIN query.)
postgresqlgetResult
returns an PostgreSQLResult
object.
This is called after completion of execution of postgresqlpqExec
.
postgresqlEscapeStrings
returns a character string which is escaped properly
so that it can be surrounded with a single quote and used as literal in SQL.
The escape procedure is dependent on the character encoding of the connection.
postgresqlEscapeBytea
returns a character string which represents the
raw data proper escape so that it can be surrounded
with a single quote and used as literal in SQL. Note that on 8.X connection E prefix
should exist before the first quote. However this changes the behaviour in 9.0, where
the E should not exist.
postgresqlUnescapeBytea
returns a raw data specified by the character string.
The character string should contain the 'escaped' bytea or hex encoded bytea
that was output from the database server.
postgresqlQuoteId
returns a character string which is quoted as identifier. Returns vector on vector arguemnt.
postgresqlTableRef
returns a character string which is quoted as identifier.
Reterns a charcter string concatenated with "." so that "dbname"."schemaname"."tablename" reference
is created upon c("dbname", "schemaname", "tablename") arguemnt.
postgresqlDataType
retuns a character string with the closest
postgresqlResultInfo
returns a list of name-value metadata pairs.
postgresqlTransactionStatement
returns a logical indicating whether the
operation succeeded or not.
positive integer specifying maximum number of open connections. The current default of 10 is hardcoded in the C code.
default number of rows to fetch (move to R/S-Plus). This default is
used in postgresqlFetch
.
The default is 500.
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).
any of the PostgreSQL DBI objects (e.g., PostgreSQLConnection
,
PostgreSQLResult
).
character vector of metadata to extract, e.g., "version", "statement", "isSelect".
logical controlling how much information to display.
Defaults to FALSE
.
an PostgreSQLDriver
object as produced by postgresqlInitDriver
.
an PostgreSQLConnection
object as produced by postgresqlNewConnection
and postgresqlCloneConnection
.
an PostgreSQLResult
object as produced by by postgresqlExecStatement
and postgresqlgetResult
.
a character string with the PostgreSQL's user name.
character string with the PostgreSQL's password.
character string with the PostgreSQL database name.
character string with the name (or IP address) of the machine
hosting the database. Default is ""
, which is
interpreted as localhost
by the PostgreSQL's API.
(optional) positive integer specifying the TCP port number that the PostgreSQL server is listening to. Consult the PostgreSQL documentation for details.
Ignored (formerly, this specified where to send server debug output)
Command-line options to be sent to the server
logical indicating whether "set datestyle to ISO" is issued upon connection. Although this is made as an option, the conversion needs to be ISO style for proper conversion of the date datatype.
logical indicating whether to close a connection that has open
result sets. The default is FALSE
.
character string holding one (and only one) SQL statement.
actual values that is written as parameters in the statement.
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 postgresqlInit
.
character vector of names (table names, fields, keywords).
a data.frame.
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 PostgreSQLSQLType
.
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.
a logical specifying whether to prepend the value
data.frame
row names or not. The default is TRUE
.
a logical specifying whether to convert DBMS field names into
legal S names. Default is TRUE
.
logical indicating whether to replace the table name
with
the contents of the data.frame value
.
The defauls is FALSE
.
logical indicating whether to append value
to the existing
table name
.
number of lines to rows to import using read.table
from the
input file to create the proper table definition. Default is 50.
field separator character.
end-of-line separator.
number of lines to skip before reading data in the input file.
the quote character used in the input file (defaults to \"
.
logical indicating whether column names that happen to be PostgreSQL
keywords be used as column names in the resulting relation (table)
being written. Defaults to FALSE
, forcing postgresqlWriteTable
to modify column names to make them legal PostgreSQL identifiers.
character string to be escaped
RAW data to be escaped
'escaped' or hex encoded binary data as character
one or more character strings to be used as identfier in SQL statement
character string indicating the file which contains the data to be copied to the PostgreSQL backend
placeholder for future use.
.PostgreSQLPkgName
(currently "RPostgreSQL"
),
.PostgreSQLPkgVersion
(the R package version),
.PostgreSQLPkgRCS
(the RCS revision),
.PostgreSQL.NA.string
(character that PostgreSQL uses to
denote NULL
on input),
.PostgreSQLSQLKeywords
(a lot!)
.conflicts.OK
.