move sqlite to s3, mature metadata summary functions
This commit is contained in:
parent
63a742d775
commit
d983f391fb
1 changed files with 147 additions and 50 deletions
22
R/helpers.R
22
R/helpers.R
|
|
@ -40,3 +40,25 @@ set_bin_path <- function(r_version_minor, build_for_minor, local_build_root, cod
|
|||
|
||||
return(path)
|
||||
}
|
||||
|
||||
add_column_if_not_exists <- function(db_name, table_name, column_name, column_type) {
|
||||
# Connect to the database
|
||||
conn <- dbConnect(SQLite(), dbname = db_name)
|
||||
|
||||
# Get the list of columns in the table
|
||||
columns <- dbGetQuery(conn, paste0("PRAGMA table_info(", table_name, ");"))
|
||||
|
||||
# Check if the column already exists
|
||||
column_exists <- any(columns$name == column_name)
|
||||
|
||||
# Add the column if it doesn't exist
|
||||
if (!column_exists) {
|
||||
dbExecute(conn, paste0("ALTER TABLE ", table_name, " ADD COLUMN ", column_name, " ", column_type, ";"))
|
||||
message(paste("Column '", column_name, "' added to table '", table_name, "'.", sep = ""))
|
||||
} else {
|
||||
message(paste("Column '", column_name, "' already exists in table '", table_name, "'.", sep = ""))
|
||||
}
|
||||
|
||||
# Disconnect from the database
|
||||
dbDisconnect(conn)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue