Learn R Programming

stacomirtools

Stacomirtools provides S4 class wrappers for DBI pool and ODBC, essentially managing database connections for stacomiR plus one or two handy functions.

Installation

You can install the development version of stacomirtools like so:

#install.packages("remotes")
#remotes::install_github(repo= "Remotes: gitlab::git@forgemia.inra.fr:stacomi/stacomirtools.git")
install.packages("stacomirtools", repos="http://R-Forge.R-project.org")

Example

The connection is established via options, for ODBC connections you need to setup the ODBC connection corresponding to your version of R (either 32 or 64 bits). You need to specify user and password.

library(stacomirtools)
# all options :
options(list(
                        stacomiR.dbname = "bd_contmig_nat",
                        stacomiR.host ="localhost",
                        stacomiR.port = "5432",
                        stacomiR.user = "mysuser",
                        stacomiR.password = "mypassword",
                        stacomiR.ODBClink = NULL,
                        stacomiR.printqueries =FALSE
                ))
req <- new("RequeteDB")
req <- query(req)

Pool Connection

For Pool, if you are running on your machine (localhost) and use postgres standard 5432 port, you need only to set options for dbname, user and password, otherwise you can connect to different hosts.

options(list(   
                stacomiR.user = "mysuser",
                stacomiR.password = "mypassword"                
        ))
# if you don't provide those you will be prompted for user and password if interactive
req <- new("RequeteDB")
req <- query(req)
# The query result is stored in req@query you can use either
req@query
# or
getquery(req)
# to get it

ODBC Connection

In windows establish ODBC link by typing ODBC in the search bar, then choose either 32 bit or 64 bit, user source add POSTGRESQL ODBC Driver (these must be prior installed with postgres via application stack manager). Then edit the datasource for the following fields. * Data Source : the name of the stacomiR.ODBClink below * Database * Serveur : on you computer localhost * User Name * Password * Port

options(list(   
                stacomiR.ODBClink = "bd_contmig_nat",
                stacomiR.user = "mysuser",
                stacomiR.password = "mypassword"                
        ))
req <- new("RequeteODBC")
req <- connect(req)
req@query

Copy Link

Version

Install

install.packages('stacomirtools')

Monthly Downloads

243

Version

0.6.0.1

License

GPL (>= 2)

Maintainer

Last Published

April 29th, 2022

Functions in stacomirtools (0.6.0.1)

connect,ConnectionODBC-method

connect method for ConnectionODBC class
is.odd

id.odd function modified from package sma
induk

unique values of a vector
connect,RequeteODBCwheredate-method

connect method loads a request to the database and returns either an error or a data.frame
connect,RequeteODBCwhere-method

connect method loads a request to the database and returns either an error or a data.frame
RequeteODBCwheredate-class

RequeteODBCwhere class
query

generic query function for
getquery

generic query function for
is.even

is.even function modified from package sma
funhtml

function used to print the html tables of output (see xtable documentation)
stacomirtools-deprecated

Deprecated Functions
connect,RequeteODBC-method

connect method loads a request to the database and returns either an error or a data.frame
connect

generic connect function for baseODBC
ex

ex fonction to write to the clipboard
query,RequeteDBwhere-method

query method loads a request to the database and returns either an error or a data.frame
query,RequeteDBwheredate-method

query method loads a request to the database and returns either an error or a data.frame
getquery,RequeteDB-method

getquery retreives the result of the query from the object
tab2df

Function to transform a ftable into dataframe but just keeping the counts, works with ftable of dim 2
stacomirtools

Stacomirtools options.
validity_ODBC

Validity method for ODBC class
validity_DB

validity function for ConnectionDB class
query,RequeteDB-method

query method loads a quert to the data and returns either an error or a data.frame
killfactor

very usefull function used to "kill" the factors, noticeably after loading with 'ODBC'
ConnectionDB-class

ConnectionDB class
RequeteODBC-class

RequeteODBC class
connect,ConnectionDB-method

connect method for ConnectionDB class
chnames

This function replaces the variable names in a data.frame
RequeteDBwheredate-class

RequeteDBwhere class
ConnectionODBC-class

ConnectionODBC class
RequeteDB-class

RequeteDB class
RequeteDBwhere-class

RequeteDBwhere class
RequeteODBCwhere-class

RequeteODBCwhere class