#' Connect to Postgresql database
#'
#' Connect to Postgresql database
#' @param dbname database name
#' @param host default localhost
#' @param ... other parameters as in dbConnect(...)
#' @examples
#' sqlConnect("poland_osm")
#' @export
sqlConnect <- function(dbname, dbdriver = "PostgreSQL", host="localhost",...){
if(dbdriver == "PostgreSQL")
{
cat("connecting to PostgreSQL")
require(RPostgreSQL)
con <<- dbConnect(dbDriver("PostgreSQL"), dbname=dbname, host=host,...)
}
if(dbdriver == "MySQL"){
cat("connecting to MySQL")
require(RMySQL)
con <<- dbConnect(dbDriver("MySQL"), dbname=dbname, host=host,...)
dbSendQuery(con, "SET SESSION group_concat_max_len = 1000000;"); dbClearResult(dbListResults(con)[[1]])
dbSendQuery(con, "SET NAMES utf8"); dbClearResult(dbListResults(con)[[1]])
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.