| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512 |
- library(ruut)
- styler:::style_active_file()
- styler:::style_active_file()
- system("ogr2ogr --long-usage")
- styler:::style_active_file()
- styler:::style_active_file()
- library(ruut)
- #'
- #' INSPIRE grid map
- #'
- library(dplyr)
- library(ruut)
- # Source: https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2
- # Temp directory
- tmp_dir <- tempdir()
- # Download link
- url <- "https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2/gis-files/estonia-shapefile/download"
- # Estonia shapefile (ZIP archive)
- map_shapefile <- "Estonia_shapefile.zip"
- # Download and sav
- saveTo <- sprintf("%s/%s", tmp_dir, map_shapefile)
- download.file(
- url = download_url,
- destfile = saveTo, method = "curl", extra = "-L"
- )
- # Unzip
- unzip(saveTo, overwrite = T, exdir = tmp_dir)
- # List of files
- ls <- list.files(path = tmp_dir, pattern = ".shp")
- ls_long <- list.files(path = tmp_dir, pattern = ".shp", full.names = T)
- tbl_names <- strsplit(x = ls, split = ".shp") %>% unlist()
- # Export to postgis
- schema <- "inspire"
- i <- 1
- config <- get_config()
- config$schema <- schema
- # New schema
- db_create_new_schema(conf = config)
- library(dplyr)
- library(ruut)
- # Source: https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2
- # Temp directory
- tmp_dir <- tempdir()
- # Download link
- url <- "https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2/gis-files/estonia-shapefile/download"
- # Estonia shapefile (ZIP archive)
- map_shapefile <- "Estonia_shapefile.zip"
- # Download and sav
- saveTo <- sprintf("%s/%s", tmp_dir, map_shapefile)
- download.file(
- url = url,
- destfile = saveTo, method = "curl", extra = "-L"
- )
- # Unzip
- unzip(saveTo, overwrite = T, exdir = tmp_dir)
- # List of files
- ls <- list.files(path = tmp_dir, pattern = ".shp")
- ls_long <- list.files(path = tmp_dir, pattern = ".shp", full.names = T)
- tbl_names <- strsplit(x = ls, split = ".shp") %>% unlist()
- # Export to postgis
- schema <- "inspire"
- i <- 1
- config <- get_config()
- config$schema <- schema
- # New schema
- db_create_new_schema(conf = config)
- print(tbl_names[i])
- config$table <- tbl_names[i]
- source <- sprintf('"%s" "%s"', tmp_dir, tbl_names[i])
- crs_source <- "-s_srs EPSG:3035"
- crs_target <- "-t_srs EPSG:4326"
- fid <- "fid"
- ruut::copy_shp_to_db(dir = tmp_dir, layer = tbl_names[i], conf = config,
- id = fid, crs_source = crs_source, crs_target = crs_target,
- geometry_type = 'POLYGON')
- dir = tmp_dir; layer = tbl_names[i]; conf = config;
- id = fid; crs_source = crs_source; crs_target = crs_target;
- geometry_type = 'POLYGON'
- length(list.files(path = dir, pattern = sprintf("%s*", layer)))
- length(list.files(path = dir, pattern = sprintf("%s*", layer))) > 0
- source <- sprintf('"%s" "%s"', dir, layer)
- source
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "%s %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
- crs_source, crs_target, geometry_type
- )
- cmd
- system(cmd)
- dir = tmp_dir; layer = tbl_names[i]; conf = config;
- id = fid; crs_source = crs_source; crs_target = crs_target;
- geometry_type = 'PROMOTE_TO_MULTI'
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "%s %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
- crs_source, crs_target, geometry_type
- )
- cmd
- ruut::db_create_new_schema(conf)
- system(cmd)
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "%s %s -nlt PROMOTE_TO_MULTI"
- ),
- config$dbname, config$host, config$port, config$user, config$password,
- config$sslmode, config$schema, source, fid, config$schema, config$table,
- crs_source, crs_target
- )
- cmd
- system(cmd)
- geometry_type = 'POLYGON'
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "%s %s -nlt %s"
- ),
- config$dbname, config$host, config$port, config$user, config$password,
- config$sslmode, config$schema, source, fid, config$schema, config$table,
- crs_source, crs_target, geometry_type
- )
- cmd
- system(cmd)
- system("ogr2ogr --long-usage")
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "-s_srs%s -t_srs -nlt %s"
- ),
- config$dbname, config$host, config$port, config$user, config$password,
- config$sslmode, config$schema, source, fid, config$schema, config$table,
- crs_source, crs_target, geometry_type
- )
- system(cmd)
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "%s %s -nlt %s"
- ),
- config$dbname, config$host, config$port, config$user, config$password,
- config$sslmode, config$schema, source, fid, config$schema, config$table,
- crs_source, crs_target, geometry_type
- )
- system(cmd)
- crs_target
- crs_source
- cmd
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "%s %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
- crs_source, crs_target, geometry_type
- )
- cmd
- crs_target
- crs_source = "EPSG:4326"
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "%s %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
- crs_source, crs_target, geometry_type
- )
- source('~/apps/R/packages/ruut/R/copy_shp_to_db.R', echo=TRUE)
- cmd
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
- crs_source, crs_target, geometry_type
- )
- copy_shp_to_db <- function(dir = NULL, layer = NULL, conf = NULL, id = "fid",
- crs_source = "EPSG:4326",
- crs_target = "EPSG:4326",
- geometry_type = "PROMOTE_TO_MULTI") {
- # Command 'ogr2ogr' help
- # system("ogr2ogr --long-usage")
- # Kontrollime kas etteantud kataloogis paiknevad failid
- if (length(list.files(path = dir, pattern = sprintf("%s*", layer))) > 0) {
- source <- sprintf('"%s" "%s"', dir, layer)
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
- crs_source, crs_target, geometry_type
- )
- ruut::db_create_new_schema(conf)
- Sys.sleep(1)
- system(cmd)
- } else {
- cat("\nEi leitud antud kataloogist faile.")
- return(NULL)
- }
- }
- ruut::copy_shp_to_db(dir = tmp_dir, layer = tbl_names[i], conf = config,
- id = fid, crs_source = crs_source, crs_target = crs_target,
- geometry_type = 'POLYGON')
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password, conf$sslmode,
- conf$schema, x, id, conf$schema, conf$table, crs_source, crs_target,
- geometry_type
- )
- source <- sprintf('"%s" "%s"', dir, layer)
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
- crs_source, crs_target, geometry_type
- )
- cmd
- system(cmd)
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "%s %s -nlt %s"
- ),
- config$dbname, config$host, config$port, config$user, config$password,
- config$sslmode, config$schema, source, fid, config$schema, config$table,
- crs_source, crs_target, geometry_type
- )
- system(cmd)
- source <- sprintf('"%s" "%s"', tmp_dir, tbl_names[i])
- crs_source <- "EPSG:3035"
- crs_target <- "EPSG:4326"
- fid <- "fid"
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- config$dbname, config$host, config$port, config$user, config$password,
- config$sslmode, config$schema, source, fid, config$schema, config$table,
- crs_source, crs_target, geometry_type
- )
- system(cmd)
- config
- conf
- config
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- config$dbname, config$host, config$port, config$user, config$password,
- config$sslmode, config$schema, source, fid, config$schema, config$table,
- crs_source, crs_target, geometry_type
- )
- system(cmd)
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --conf PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, id, conf$schema, conf$table,
- crs_source, crs_target, geometry_type
- )
- system(cmd)
- cmd <- sprintf(
- paste0(
- "ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL ",
- "PG:\" dbname='%s' host=%s port=%d user='%s' password='%s' ",
- "sslmode=%s active_schema=%s \" -lco DIM=2 %s -overwrite -nlt GEOMETRY ",
- "-lco GEOMETRY_NAME=geometry -lco FID=%s -nln %s.%s ",
- "-s_srs %s -t_srs %s -nlt %s"
- ),
- conf$dbname, conf$host, conf$port, conf$user, conf$password,
- conf$sslmode, conf$schema, source, fid, conf$schema, conf$table,
- crs_source, crs_target, geometry_type
- )
- system(cmd)
- styler:::style_active_file()
- library(ruut)
- styler:::style_active_file()
- styler:::style_active_file()
- library(ruut)
- styler:::style_active_file()
- styler:::style_active_file()
- library(ruut)
- styler:::style_active_file()
- library(ruut)
- styler:::style_active_file()
- styler:::style_active_file()
- library(ruut)
- styler:::style_active_file()
- styler:::style_active_file()
- styler:::style_active_file()
- styler:::style_active_file()
- library(ruut)
- conf <- ruut::get_config()
- conf
- styler:::style_active_file()
- library(ruut)
- library(ruut)
- conn <- ruut::db_connect()
- config <- get_config()
- config$schema <- "public"
- conf = config
- 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
- res <- DBI::dbGetQuery(conn, q)
- res
- res <- as.array(DBI::dbGetQuery(conn, q))
- res <- DBI::dbGetQuery(conn, q)
- res[,'table_name']
- styler:::style_active_file()
- library(ruut)
- config
- config$schema <- 'maaamet'
- db_schema_tablenames(conf = config)
- library(ruut)
- styler:::style_active_file()
- library(ruut)
- library(ruut)
- styler:::style_active_file()
- construct_qgis_output_result_to_beter_format <- function(str = "") {
- #' str - Processing algorithm… Algorithm '......' starting…
- #' Input parameters: -> kopeerin need loogilistes sulgudes
- #' olevad väärtused argumendi "str" väärtuseks.
- str <- "{ 'CREATEINDEX' : True, 'DATABASE' : 'Data', 'DROP_STRING_LENGTH' : False, 'ENCODING' : 'UTF-8', 'FORCE_SINGLEPART' : False, 'GEOMETRY_COLUMN' : 'geometry', 'INPUT' : '/data/gpkg/teed/teed_l.gpkg|layername=teed_l', 'LOWERCASE_NAMES' : True, 'OVERWRITE' : True, 'PRIMARY_KEY' : 'fid', 'SCHEMA' : 'data', 'TABLENAME' : 'mikihiir' }"
- str <- gsub("'", "", str)
- str <- gsub(":", "=", str)
- str <- gsub(" ", "", str)
- str <- gsub(",", "',", str)
- str <- gsub("=", "='", str)
- str <- gsub("'True'", "1", str)
- str <- gsub("'False'", "0", str)
- str <- gsub(",", ",\n", str)
- str <- gsub("[{]", "\nalgorithm=algorithm,\n", str)
- str <- gsub("[}]", "'\n", str)
- str <- gsub("layername='", "layername=", str)
- cat(str)
- str
- }
- str <- "{ 'CREATEINDEX' : True, 'DATABASE' : 'Data', 'DROP_STRING_LENGTH' : False, 'ENCODING' : 'UTF-8', 'FORCE_SINGLEPART' : False, 'GEOMETRY_COLUMN' : 'geometry', 'INPUT' : '/data/gpkg/teed/teed_l.gpkg|layername=teed_l', 'LOWERCASE_NAMES' : True, 'OVERWRITE' : True, 'PRIMARY_KEY' : 'fid', 'SCHEMA' : 'data', 'TABLENAME' : 'mikihiir' }"
- params <- construct_qgis_output_result_to_beter_format(str = str)
- 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)
|