gmConnectServer: Geometallurgy Database connection

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/DBinterface.R

Description

A geometallurgy database is a database on a relational database server. It can handle very general and recursive information for the transparent access to whole projects from a statistical analysis software.

Usage

1
2
3
4
5
6
7
8
gmConnectServer(..., server="localhost", dbuser, asDefault=TRUE)
gmDisconnectServer(db=getOption("gmDB"))
gmCreateDB(..., dbName="gmDatabase", admin=NULL, adminPwd=NULL)
gmListVariables(pattern="%",db=getOption("gmDB"))
gmListVariableTypes(db=getOption("gmDB"))
gmDBSummary(db=getOption("gmDB"))
gmEscapeStrings(s,db=getOption("gmDB"))
gmRequest(fun, parameters, db)

Arguments

...

Arguments to dbConnect from RMySQL to contact the database server.

asDefault

Logical indicating whether being used as default connection.

db

A database connection object as returned by gmConnectServer.

server

The address of the server, where the R server.

dbuser

A list giving the login and password of the user working in the geometallurgical database.

dbName

String stating the name for the database to-be.

admin

The login for the administrator/the first database user.

adminPwd

The password for the administrator/the database user.

pattern

An SQL-regular expression (for LIKE) to specify the variable names to be listed.

s

A character vector of strings to be escaped.

fun

A function name.

parameters

A list of parameters for the function fun

Details

The geometallurgy database provides an abstraction layer to a relational database storage of many eventually differently structured datasets, which might contain datasets recursively. Only in this very complex structure it is possible to respresent the data needed for typical statistical tasks of geometallurgy.

The data storage starts from a common root object "root", which contains a variable set variable "project".

The Database connection is handled by gmConnectServer and gmDisconnectServer. In order to assure a proper rights management, the user does not directly connect to the database. We implemented a two level security system. The first level represents the connection to the database server. Therefore a general user on the server is needed, who is provided with the required rights to access and manipulate the database itself. The corresponding credentials are compiled in ... and will be forwarded to dbConnect from the package RMySQL. Data access happens on the second level, where the dbuser is involved. His credentials are checked against the information stored in the database. Everytime some information is queried from the database, the result is given according to the rights this user owns on this particular data. If no user is explicitly given during the function call, i.e. dbuser is missing, gmConnectServer will start a dialog to access the (db)user's credentials. Same is true, if information on the general database server user is omitted.

In order to create a compatible database, you may gmCreateDB. A connection to the given MySQL-server is established and a new database of the given dbName is created. Furthermore first variables to realise the user/rights management are provided. Additonally a first user/admin is added to the database with the given username and password, so that this user is able to login to the database afterwards. If no MySQL login, MySQL password or MySQL host is given, a shiny app requests these information. Same happens if no login or password is given for the first user/admin.

This package can be used in a client - server approach. Then gmConnectServer will not return a database connection, but a socket connection. It will be used to send the commands to an R server. The actual translation from R into SQL is then done on the server. Again only the accessible data according to the user's rights will be returned. In order to activate the client-server mode, use the argument server to state the server you want to access. By default server is set to localhost.

gmRequest is an internal function. It should not be called directly. Depending on the class of database connection used, it decides if the fun is evaluated locally or handed over to the server.

Value

gmConnectServer

Returns a server connection to be used in subsequent calls. It is assigned to the hidden variable .gmDB. If server ist set to localhost, it will be a database connection instead.

gmDisconnectServer

Returns the same as gmDisconnectDB. Additionally .gmDB is set to zero.

gmCreateDB

No return value.

gmListVariables

Returns a dataframe describing the variables defined in the geometallurgy database.

gmListVariableTypes

Returns a dataframe describing the variable types defined in the geometallurgy database.

gmDBSummary

Returns a dataframe giving variable name, variable type and number of objects for each variable.

Author(s)

K. Gerald van den Boogaart, S. Matos Camacho

See Also

MySQLConnection-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
gmCreateDB(MySQL(), user="mysqlUser", password="mysqlPassword", host="mysqlServer", 
  dbName="myDB", admin="admin",adminPwd="myAdminPassword")
gmConnectServer(MySQL(), group="test", server="localhost")
gmListVariables(pattern=".*",db=.gmDB)
gmListVariableTypes(db=.gmDB)
gmDBSummary(db=.gmDB)
gmDisconnectServer()


## End(Not run)

gmDatabase documentation built on May 2, 2019, 9:31 a.m.