From a4500684bbb9e697392aa05d1503337446a28bc4 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 25 Jul 2024 00:28:09 +0200 Subject: [PATCH] add metadata query funs --- R/metadata-query.R | 23 +++++++++++++++++++++++ man/list_metadata_tables.Rd | 11 +++++++++++ man/query_metadata_table.Rd | 14 ++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 R/metadata-query.R create mode 100644 man/list_metadata_tables.Rd create mode 100644 man/query_metadata_table.Rd diff --git a/R/metadata-query.R b/R/metadata-query.R new file mode 100644 index 0000000..a0cbc42 --- /dev/null +++ b/R/metadata-query.R @@ -0,0 +1,23 @@ +#' Query a specific table in the Postgres database containing the metadata +#' @param table Table name. See [list_metadata_tables()] for valid tables. +#' @importFrom DBI dbConnect dbGetQuery +#' @importFrom RPostgres Postgres +#' @importFrom dplyr tbl +query_metadata_table <- function(table = "single_builds") { + con <- DBI::dbConnect(RPostgres::Postgres(), + dbname = "build_metadata", host = "postgres-arm-binaries-r.devxy.io", + port = 15432, user = "arm_binaries", password = Sys.getenv("PGPASS") + ) + metadata <- tbl(con, table) + return(metadata) +} + +#' List existing database tables +#' @export +list_metadata_tables <- function() { + con <- DBI::dbConnect(RPostgres::Postgres(), + dbname = "build_metadata", host = "postgres-arm-binaries-r.devxy.io", + port = 15432, user = "arm_binaries", password = Sys.getenv("PGPASS") + ) + dbListTables(con) +} diff --git a/man/list_metadata_tables.Rd b/man/list_metadata_tables.Rd new file mode 100644 index 0000000..30d0a7c --- /dev/null +++ b/man/list_metadata_tables.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/metadata-query.R +\name{list_metadata_tables} +\alias{list_metadata_tables} +\title{List existing database tables} +\usage{ +list_metadata_tables() +} +\description{ +List existing database tables +} diff --git a/man/query_metadata_table.Rd b/man/query_metadata_table.Rd new file mode 100644 index 0000000..1a47bf8 --- /dev/null +++ b/man/query_metadata_table.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/metadata-query.R +\name{query_metadata_table} +\alias{query_metadata_table} +\title{Query a specific table in the Postgres database containing the metadata} +\usage{ +query_metadata_table(table = "single_builds") +} +\arguments{ +\item{table}{Table name. See \code{\link[=list_metadata_tables]{list_metadata_tables()}} for valid tables.} +} +\description{ +Query a specific table in the Postgres database containing the metadata +}