Skip to content
Snippets Groups Projects
Commit 16995f15 authored by ronan.vignard's avatar ronan.vignard
Browse files

Modification de l'exemple + ajout du paramètre host

parent 0c0e6965
No related branches found
No related tags found
6 merge requests!67Passage en version 0.1.6,!66Intégration de la fonction download_files_from_list(),!65Correction d'un bug + création des tests pour fix_encoding_variable(),!64Création des tests pour insert_into_table(),!63Ajout des tests pour import_and_merge_tables() + adaptation de create_dummy(),!62Tests pour check_structure_table() + évolution de create_dummy()
......@@ -22,17 +22,26 @@
#' @export
#' @examples
#' \dontrun{
#' # Création d'un dataframe à partir d'un fichier XLSX
#' data_ars_2022 <- import_xlsx(
#' filepath = system.file("Nitrates_2022.xlsx", package = "collectr"),
#' sheet = 1,
#' row = 2)
#' # Création d'un dataframe de test
#' test <- data.frame(
#' id = 1:5,
#' name = c("Alice", "Bob", "Charlie", "David", "Eve"),
#' birthdate = c("1990-01-15", "1985-06-22", "1992-09-10", "1988-03-05", "1995-12-30"),
#' value = rnorm(5)
#' )
#' # Création d'une table de test en base
#' create_dummy(host = "localhost",
#' database = "collectr",
#' schema = "public",
#' table = "dummy",
#' role = "runner")
#' # Utilisation de la fonction check_structure_table()
#' check_structure_table(database = "si_eau",
#' schema = "nitrates",
#' table = "nitrate_data_analyse_ars_test",
#' dataframe = data_ars_2022,
#' role = "admin")
#' check_structure_table(host = "localhost",
#' database = "collectr",
#' schema = "public",
#' table = "dummy",
#' dataframe = test,
#' role = "runner")
#' }
check_structure_table <- function(host, database, schema, table, dataframe, role) {
# Se connecter à la base de données PostgreSQL
......@@ -42,7 +51,8 @@ check_structure_table <- function(host, database, schema, table, dataframe, role
ecoSQL = FALSE)
# Vérifier si la table existe dans la base de données
if (!table_exists(database = database, schema = schema, table = table, role = role)) {
if (!table_exists(host = host, database = database, schema = schema,
table = table, role = role)) {
stop("La table sp\u00e9cifi\u00e9e n\'existe pas dans la base de donn\u00e9es.")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment