Skip to contents

Run a custom query

Usage

aact_custom_query(con, query)

Arguments

con

Database connection object

query

SQL query string

Value

A data frame with the query results

Examples

# \donttest{
# Set environment variables for database credentials in .Renviron and load it
# readRenviron(".Renviron")

# Connect to the database
con <- aact_connection(Sys.getenv('user'), Sys.getenv('password'))
#> Error in postgresqlNewConnection(drv, ...): RPosgreSQL error: could not connect runner@aact-db.ctti-clinicaltrials.org:5432 on dbname "aact": connection to server at "aact-db.ctti-clinicaltrials.org" (174.138.61.222), port 5432 failed: fe_sendauth: no password supplied

# Run a custom query
query <- "SELECT nct_id, source, enrollment, overall_status FROM studies LIMIT 5;"
results <- aact_custom_query(con, query)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'conn' in selecting a method for function 'dbGetQuery': object 'con' not found

# Print the results
print(results)
#> Error in eval(expr, envir, enclos): object 'results' not found
# }