Эх сурвалжийг харах

Lisatud 'db_schema_tablenames'.

Ardo Kubjas 5 жил өмнө
parent
commit
558d46039b

+ 16 - 16
.Rhistory

@@ -1,19 +1,3 @@
-else
-return(FALSE)
-}
-aaa <- db_is_shema_exist(schema = "x_matsalu")
-aaa <- db_is_shema_exist(schema = "x_matsalu")
-aaa <- db_is_shema_exist(schema = "xx_matsalu")
-schema = "xx_matsalu"
-schema %in% db_all_schemas()
-schema %in% db_all_schemas()
-if(schema %in% db_all_schemas())
-TRUE
-else
-FALSE
-if(schema %in% db_all_schemas())
-TRUE
-else
 FALSE
 if(schema %in% db_all_schemas())
 TRUE
@@ -510,3 +494,19 @@ 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)

+ 1 - 0
NAMESPACE

@@ -9,6 +9,7 @@ export(db_all_schemas)
 export(db_connect)
 export(db_create_new_schema)
 export(db_is_shema_exist)
+export(db_schema_tablenames)
 export(db_table_colnames)
 export(get_config)
 export(pk_bbox)

+ 25 - 0
R/db_schema_tablenames.R

@@ -0,0 +1,25 @@
+#' Database schema table names list
+#'
+#' Andmebaasi schema tabelite nimekiri.
+#' @param conf A list() of configuration variables. Default values \code{\link[ruut]{get_config}}.
+#' @seealso [ruut::db_connect()], [ruut::get_config()]
+#' @keywords database, table, schema
+#' @export
+#' @examples
+#' \dontrun{
+#'
+#' config <- get_config()
+#' config$schema <- "public"
+#' db_schema_tablenames(conf = config)
+#' }
+db_schema_tablenames <- function(conf) {
+  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)
+  # Disconnect
+  res[, "table_name"]
+}

+ 29 - 0
man/db_schema_tablenames.Rd

@@ -0,0 +1,29 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/db_schema_tablenames.R
+\name{db_schema_tablenames}
+\alias{db_schema_tablenames}
+\title{Database schema table names list}
+\usage{
+db_schema_tablenames(conf)
+}
+\arguments{
+\item{conf}{A list() of configuration variables. Default values \code{\link[ruut]{get_config}}.}
+}
+\description{
+Andmebaasi schema tabelite nimekiri.
+}
+\examples{
+\dontrun{
+
+config <- get_config()
+config$schema <- "public"
+db_schema_tablenames(conf = config)
+
+}
+}
+\seealso{
+\code{\link[=db_connect]{db_connect()}}, \code{\link[=get_config]{get_config()}}
+}
+\keyword{database,}
+\keyword{schema}
+\keyword{table,}