|
|
@@ -1,97 +1,3 @@
|
|
|
-paste0(getwd(), "/R/db_all_schemas.R")
|
|
|
-source(paste0(getwd(), "/R/db_all_schemas.R"))
|
|
|
-db_is_shema_exist(schema = "x_matsalu")
|
|
|
-db_is_shema_exist(schema = "x_matsalu")
|
|
|
-db_is_shema_exist(schema = "zx_matsalu")
|
|
|
-styler:::style_active_file()
|
|
|
-styler:::style_active_file()
|
|
|
-db_create_new_schema <- function(conf) {
|
|
|
-source(paste0(getwd(), "/R/db_is_shema_exist.R"))
|
|
|
-if(db_is_shema_exist(schema)) {
|
|
|
-conn <- db_connect()
|
|
|
-DBI::dbExecute(conn, sprintf(
|
|
|
-"-- DROP SCHEMA x_matsalu;
|
|
|
-CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
|
|
|
-))
|
|
|
-}
|
|
|
-}
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf$schema <- "x_valga"
|
|
|
-db_create_new_schema(conf)
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf$schema <- "x_valga1"
|
|
|
-db_create_new_schema(conf)
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf
|
|
|
-conf$schema <- "x_valga1"
|
|
|
-conf
|
|
|
-db_create_new_schema(conf)
|
|
|
-conf$schema
|
|
|
-db_create_new_schema <- function(conf) {
|
|
|
-source(paste0(getwd(), "/R/db_is_shema_exist.R"))
|
|
|
-if(!db_is_shema_exist(conf$schema)) {
|
|
|
-conn <- db_connect()
|
|
|
-DBI::dbExecute(conn, sprintf(
|
|
|
-"-- DROP SCHEMA x_matsalu;
|
|
|
-CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
|
|
|
-))
|
|
|
-}
|
|
|
-}
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf$schema <- "x_valga1"
|
|
|
-db_create_new_schema(conf)
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf$schema <- "x_valga1"
|
|
|
-db_create_new_schema(conf)
|
|
|
-library(ruut)
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf
|
|
|
-conf$schema <- "x_valga1"
|
|
|
-db_create_new_schema(conf)
|
|
|
-db_create_new_schema <- function(conf) {
|
|
|
-source(paste0(getwd(), "/R/db_is_shema_exist.R"))
|
|
|
-if(!db_is_shema_exist(conf$schema)) {
|
|
|
-conn <- db_connect()
|
|
|
-DBI::dbExecute(conn, sprintf(
|
|
|
-"-- DROP SCHEMA x_matsalu;
|
|
|
-CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
|
|
|
-))
|
|
|
-}
|
|
|
-}
|
|
|
-db_create_new_schema(conf)
|
|
|
-DBI::dbDisconnect(conn)
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf$schema <- "x_valga1"
|
|
|
-db_create_new_schema(conf)
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf$schema <- "x_valga1"
|
|
|
-db_create_new_schema(conf)
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf$schema <- "x_valga"
|
|
|
-db_create_new_schema(conf)
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf$schema <- "x_valga"
|
|
|
-db_create_new_schema(conf)
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf$schema <- "x_valga"
|
|
|
-db_create_new_schema(conf)
|
|
|
-conf <- ruut::get_config()
|
|
|
-conf$schema <- "x_valga"
|
|
|
-db_create_new_schema(conf)
|
|
|
-styler:::style_active_file()
|
|
|
-library(ruut)
|
|
|
-styler:::style_active_file()
|
|
|
-library(ruut)
|
|
|
-styler:::style_active_file()
|
|
|
-library(ruut)
|
|
|
-library(ruut)
|
|
|
-library(ruut)
|
|
|
-library(ruut)
|
|
|
-library(ruut)
|
|
|
-ogr2ogr --long-usage
|
|
|
-system("ogr2ogr --long-usage")
|
|
|
-library(ruut)
|
|
|
-library(ruut)
|
|
|
library(ruut)
|
|
|
styler:::style_active_file()
|
|
|
styler:::style_active_file()
|
|
|
@@ -510,3 +416,97 @@ styler:::style_active_file()
|
|
|
styler:::style_active_file()
|
|
|
library(ruut)
|
|
|
library(ruut)
|
|
|
+styler:::style_active_file()
|
|
|
+library(ruut)
|
|
|
+library(ruut)
|
|
|
+library(ruut)
|
|
|
+styler:::style_active_file()
|
|
|
+library(ruut)
|
|
|
+library(ruut)
|
|
|
+library(ruut)
|
|
|
+library(ruut)
|
|
|
+styler:::style_active_file()
|
|
|
+construct_ogr2ogr_PG_connect_str()
|
|
|
+construct_ogr2ogr_PG_connect_str <- function(gpkg_home = "/tmp", gpkg_file = "test", gpkg_table = "layer_one") {
|
|
|
+dsn <- sprintf("%s/%s.gpkg", gpkg_home, gpkg_file)
|
|
|
+ogr <- sprintf("ogr:dbname='%s'", dsn)
|
|
|
+output <- sprintf('%s table=\"%s\" (geometry)', ogr, gpkg_table)
|
|
|
+output
|
|
|
+}
|
|
|
+construct_ogr2ogr_PG_connect_str()
|
|
|
+library(ruut)
|
|
|
+styler:::style_active_file()
|
|
|
+conf <- ruut::get_config()
|
|
|
+PG <- sprintf(
|
|
|
+'postgres://dbname=\'%s\' host=%s port=%s user=\'%s\' password=\'%s\' sslmode=%s key=\'id\' srid=3301 type=Polygon checkPrimaryKeyUnicity=\'1\' table=\"%s\".\"%s\" (geometry)',
|
|
|
+conf$dbname, conf$host, conf$port, conf$user, conf$password, conf$sslmode, conf$schema, conf$table
|
|
|
+)
|
|
|
+PG
|
|
|
+styler:::style_active_file()
|
|
|
+PG
|
|
|
+library(ruut)
|
|
|
+conf <- ruut::get_config()
|
|
|
+construct_to_gpkg_output_postgres_str <- function(conf = NULL) {
|
|
|
+if (is.null(conf)) conf <- ruut::get_config()
|
|
|
+PG <- sprintf(
|
|
|
+'postgres://dbname=\'%s\' host=%s port=%s user=\'%s\' password=\'%s\' sslmode=%s key=\'id\' srid=3301 checkPrimaryKeyUnicity=\'1\' table=\"%s\".\"%s\" (geometry)',
|
|
|
+conf$dbname, conf$host, conf$port, conf$user, conf$password, conf$sslmode, conf$schema, conf$table
|
|
|
+)
|
|
|
+PG
|
|
|
+}
|
|
|
+construct_to_gpkg_output_postgres_str(conf =
|
|
|
+conf
|
|
|
+)
|
|
|
+conf <- ruut::get_config()
|
|
|
+conf
|
|
|
+library(ruut)
|
|
|
+conf <- ruut::get_config()
|
|
|
+conf
|
|
|
+conf <- ruut::get_config()
|
|
|
+construct_to_gpkg_output_file_str(conf = conf)
|
|
|
+construct_to_gpkg_output_file_str <- function(conf = conf) {
|
|
|
+dsn <- sprintf("%s/%s.gpkg", conf$gpkg_home, conf$gpkg_file)
|
|
|
+ogr <- sprintf("ogr:dbname='%s'", dsn)
|
|
|
+output <- sprintf('%s table=\"%s\" (geometry)', ogr, conf$gpkg_table)
|
|
|
+output
|
|
|
+}
|
|
|
+construct_to_gpkg_output_file_str(conf = conf)
|
|
|
+styler:::style_active_file()
|
|
|
+library(ruut)
|
|
|
+config <- get_config()
|
|
|
+llibrary(ruut)
|
|
|
+library(ruut)
|
|
|
+config <- get_config()
|
|
|
+config$schema <- "data"
|
|
|
+db_schema_tablenames(conf = config)
|
|
|
+conn <- ruut::db_connect()
|
|
|
+q <- sprintf("select t.table_name
|
|
|
+from information_schema.tables t
|
|
|
+where t.table_schema = '%s'
|
|
|
+and t.table_type = 'BASE TABLE'
|
|
|
+order by t.table_name;", conf$schema)
|
|
|
+res <- DBI::dbGetQuery(conn, q)
|
|
|
+conn <- ruut::db_connect()
|
|
|
+q <- sprintf("select t.table_name
|
|
|
+from information_schema.tables t
|
|
|
+where t.table_schema = '%s'
|
|
|
+and t.table_type = 'BASE TABLE'
|
|
|
+order by t.table_name;", conf$schema)
|
|
|
+conf$schema
|
|
|
+config <- get_config()
|
|
|
+config$schema <- "data"
|
|
|
+conf <- get_config()
|
|
|
+conf$schema <-
|
|
|
+"data"
|
|
|
+conn <- ruut::db_connect()
|
|
|
+q <- sprintf("select t.table_name
|
|
|
+from information_schema.tables t
|
|
|
+where t.table_schema = '%s'
|
|
|
+and t.table_type = 'BASE TABLE'
|
|
|
+order by t.table_name;", conf$schema)
|
|
|
+res <- DBI::dbGetQuery(conn, q)
|
|
|
+nrow(res)
|
|
|
+if(nrow(res)==0) NULL else res[, "table_name"]
|
|
|
+if(nrow(res)==0) NULL else res[, "table_name"]
|
|
|
+styler:::style_active_file()
|
|
|
+library(ruut)
|