Extract database connection info {PivotalR} | R Documentation

## Utilities for extracting related information about a database connection

### Description

For a given database connection, these functions return the user name, host, database name, info about database management system, connection, the version of MADlib installed on this database, the schema name of MADlib installation, and the R package that is used to connect to this database.

### Usage

    user(conn.id = 1)

    host(conn.id = 1)

    dbname(conn.id = 1)

    dbms(conn.id = 1)

    conn(conn.id = 1)

    port(conn.id = 1)

    madlib(conn.id = 1)

    madlib.version(conn.id = 1)

    schema.madlib(conn.id = 1)

    conn.pkg(conn.id = 1)

### Arguments

`conn.id` | Default value is 1. The database connection ID number `con.id`. It is an integer.

### Value

For `user`, a string, which is the user name.

For `host`, a string, which is the host address.

For `dbname`, a string, which is the database name.

For `dbms`, a string, which is DBMS version information.

For `conn`, an object of DBI connection, which can be directly used with packages such as RPostgreSQL.

For `port`, an integer, which is the port number of the connection.

For `madlib`, a string, which is the MADlib version information.

For `madlib.version`, a string, exactly the same as `madlib`.

For `schema.madlib`, a string, which is the schema name of MADlib installation.

For `conn.pkg`, a string, which is the name of the R package that has been used to connect to this database.

### Author(s)

Author: Predictive Analytics Team at Pivotal Inc.

Maintainer: Frank McQuillan, Pivotal Inc. fmcquillan@pivotal.io

### See Also

`db.connect` creates connections to the databases.

`db.disconnect` disconnects an existing connection.

`db.list` lists all the current connections with their information.

`conn.eql` tests whether two connections are actually the same one.

### Examples

    ## Not run:

    ## set up the database connection
    ## Assume that .port is port number and .dbname is the database name
    cid1 <- db.connect(port = .port, dbname = .dbname, verbose = FALSE)
    cid2 <- db.connect(port = .port, dbname = .dbname, verbose = FALSE)

    user(cid1)
    host(cid2)
    dbname(cid1) # use default connection 1
    dbms(cid1)
    madlib(cid1)
    madlib.version(cid1)
    schema.madlib(cid1)
    conn.pkg(cid1)

    ## conn is mostly for other packages
    con <- conn(cid1) # get the connection object
    dbListTables(con) # directly use functions in package RPostgreSQL

    ## This package provides a better function to list all tables/views
    db.objects(cid1) # list all tables/views with their schema in connection 1

    db.disconnect(cid1, verbose = FALSE)
    db.disconnect(cid2, verbose = FALSE)

    ## End(Not run)

[Package PivotalR version 0.1.18.3.1 Index]