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)
gmConnectServer
.login
and password
of the user working in the geometallurgical database.fun
.gmDB
.
If server
ist set to localhost, it will be a database connection instead.gmDisconnectDB
. Additionally .gmDB
is set to zero. 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.
MySQLConnection-class
## 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)
Run the code above in your browser using DataLab