Description Usage Arguments Details Functions Examples
Resources to manage connections, to test the status of connections, as well as functions to get details (attributes) about a connection object that exists within the connection pool.
1 2 3 4 5 6 7 8 9 | SeeConn(db = NULL, what = NULL)
SeeOpenConns()
SeeClosedConns()
ConnStatus(db = NULL)
ListConnAttr()
|
db |
A character value representing the name of a database whose connection's attributes need to be accessed |
what |
A character value representing the attribute name to access |
As a developer creating a custom query function, you may need the ability to know, for example, if a connection is open and how long it's been open. These are known as attributes and all existing connection objects have the following set of attributes:
Database
Name of database
Status
Open/Closed
Initiator
The first opener of the connection
Opener
Who opened a closed connection
Closer
Who closed an open connection
Requestor
Who requested a connection (e.g. tried to open an already
open connection)
TimeInitiated
When was the connection first opened (timestamp resets
when connection is closed)
TimeOpened
When did the connection's status change from Closed to Open
TimeClosed
When did the connection's status change from Open to Closed
TimeRequested
When was the connection was last requested (timestamp)
DurSinceInit
Duration since connection was initiated
DurSinceRequest
Duration since a connection was last requested
DurationOpen
Duration that connection has been open
DurationClosed
Duration that connection has been closed
AccessCount
Number of times the connection has been requested/opened since init
SeeConn
: A function to "see" a particular connection objects attributes.
SeeOpenConns
: See attributes for all open connections
SeeClosedConns
: See attributes for all closed connections
ConnStatus
: Prints status of all connection in the pool
ListConnAttr
: A function that provides a quick lookup of
all attribute names that an object will have
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Not run:
# Common developer helper functions #
db <- "a_database_name"
CheckDB(db) # trys to find a matching database name, returns error if not
AccessInfo(db) # access info for specified db
ValidDB() # What DBs are configured in the package?
ConnString(db) # Connection string for db?
# Opening/Closing Connections #
OpenDB(db) # Returns 1 on success
CloseDB(db) # Returns 1 on success
CloseDB(db) # Warning if closing db that is already closed
CloseDB("blah") # Error if db doesn't exist
# Manage connections #
ConnExists(db) # Returns TRUE for any open/closed connections
ConnPool() # Returns all the connection (names) in the pool
ConnStatus() # Returns a table showing status for all configured dbs
# Use should be rare to not at all #
GetConn(db) # Retrieve connection object
Clean(db) # Removes connection from pool (usually because of error)
Clean() # Removes ALL connections from pool (usually because of error)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.