dbConnect-methods {RPostgreSQL}R Documentation

Create a connection object to an PostgreSQL DBMS

Description

These methods are straight-forward implementations of the corresponding generic functions.

Methods

drv
an object of class PostgreSQLDriver, or the character string "PostgreSQL" or an PostgreSQLConnection.
conn
an PostgreSQLConnection object as produced by dbConnect.
host
Name or the numeric IPaddress of the host to connect to. If address is specified, it should be in the standard IPv4 address format, e.g., 172.28.40.9 or if your machine supports IPv6, you can also use those addresses. The default is to connect to localhost.
dbname
The database name. Defaults to 'template1' i.e if this argument is not specified, it is taken as dbname="template1".
user
PostgreSQL user name to connect as. Defaults to be the same as the operating system name of the user running the application.
password
Password to be used if the server demands password authentication.
port
Port number to connect to at the server host, or socket file name extension for Unix-domain connections.
tty
Ignored (formerly, this specified where to send server debug output).
options
Command-line options to be sent to the server

Side Effects

A connection between R/S-Plus and an PostgreSQL server is established. The current implementation supports up to 100 simultaneous connections.

References

See the Database Interface definition document DBI.pdf in the base directory of this package or http://stat.bell-labs.com/RS-DBI.

See Also

PostgreSQL, dbConnect, dbSendQuery, dbGetQuery, fetch, dbCommit, dbGetInfo, dbReadTable.

Examples

## Not run: 
# create an PostgreSQL instance and create one connection.
drv <- dbDriver("PostgreSQL")

# open the connection using user, passsword, etc., as
con <- dbConnect(drv, dbname = "postgres")

# Run an SQL statement by creating first a resultSet object
rs <- dbSendQuery(con, statement = paste(
                      "SELECT itemCode, itemCost, itemProfit",
                      "FROM sales",
                      "SORT BY itemName"));

# we now fetch records from the resultSet into a data.frame
df <- fetch(rs, n = -1)   # extract all rows
dim(df)
## End(Not run)

[Package RPostgreSQL version 0.1-6 Index]