| 1234567891011121314151617181920212223242526 |
- #' PostgreSQL - Create 'postgis' database
- #' @details Postgis'i andmebaasi loomine.
- #' @param host Name or the numeric IPaddress of the host to connect to.
- #' @param dbname The database name.
- #' @param user PostgreSQL user name to connect as. Defaults to be the same as the operating system name of the user running the application.
- #' @param password Password to be used if the server demands password authentication.
- #' @param port Port number to connect to at the server host.
- #' @return return message.
- #' @seealso \code{\link{myPostgresConnect}}, \code{\link{myPostgresDropTable}},
- #' \code{\link{myPostgresCreateGisDb}}, \code{\link{myPostgresImprotShp}}
- #' @examples \dontrun{
- #' con <- myPostgresCreateGisDb(host = '192.168.255.26', port = 5432,
- #' user = 'ardo', password = '247848', dbname = 'xxx')
- #'
- #' }
- #'
- #' @export
- #'
- myPostgresCreateGisDb <- function(host = '192.168.255.26', port = 5432, user = 'ardo', password = '247848', dbname = NULL) {
- if(is.null(dbname)) {message("Palun sisesta andmebaasi nimi!"); return(NULL)}
- system(paste0("export PGPASSWORD='", password, "' && createdb -U ", user, " -h ", host, " -p ", port, " ", dbname, ";"))
- # "psql -U ardo -h 192.168.255.26 -p 5432 -d shp -c 'CREATE EXTENSION hstore; CREATE EXTENSION postgis;'"
- system(paste0("export PGPASSWORD='", password, "' && psql -U ", user, " -d ", dbname, " -h ", host, " -p ", port, " -c 'CREATE EXTENSION hstore; CREATE EXTENSION postgis;'"))
- message(paste0("Genereeriti postgis'i andmebaas ", dbname, "."))
- }
|