
  
## ------------------------------ ##
##        QUERY EXECUTION         ##
## ------------------------------ ##


  limit <- if (is.numeric(TEST.RUN)) TEST.RUN else if(isTRUE(TEST.RUN)) 10 else NULL

  if (length(schema) > 1 && length(schema) == length(TBL) ) 
    warning ("\n `schema` and `TBL` each have multiple lengths and will result in ", length(TBL) * length(schema) ," total tables queried.\nTo create schema/TBL combinations in parallel, use `mapply`.")

  if (length(schema)) {
    TBL    <- sapply(schema, schemaPaste, TBL)
    schema <- NULL
  }

  #### Queries will be saved in a list. 
  ##     QRY holds the string sent as the SQL Query
  ##    QRES holds the results that were returned by the query
  ##    q.nm is the list names that correspons to both of these
  ## 
  if (!exists("QRY"))
    QRY <- list()
  if (!exists("QRES"))
    QRES <- list()

  qry_timestamp <- timeStamp(frmt=frmt.monthday_time)

  q.nm <- paste0(q.nm.prefx, TBL, "_UPC_", if(length(schema)) paste0(schema, "_"), qry_timestamp)
  # Construct the query

  QRY[q.nm] <- sapply(TBL, makeQry
                      , colsToPull=colsToPull, whereIn=whereIn, schema=schema
                      , dateCol=date_col, dateMin=dateMin, dateMax=dateMax
                      , limit=limit, useProduction=useProduction)

  # Submit the qruery and store the results
  try(dbDisconnect(con))

  con <- getDB()
  QRES[q.nm] <- lapply(QRY[q.nm], runQry, verbose=TRUE)

  ## ------------------------------ ##
  try(dbDisconnect(con))
  try(detach(package:RPostgreSQL), silent=TRUE)
  saveImageTo()
  ## ------------------------------ ##



## ------------------------------ ##
##         RELEASE DATE           ## 
##        QUERY EXECUTION         ##
## ------------------------------ ##
  if (RELEASE.DATES) {
    q.nm.rel <- paste0("releaseDates", "_", qry_timestamp)
    QRES[[q.nm.rel]] <- getReleaseDates(values=SomLivre[, upc], id.col="releaseId", id.col.AS="upc", numericValues=TRUE)
    q.nm <- c(q.nm, q.nm.rel)
  }
  try(dbDisconnect(con))
  try(detach(package:RMySQL), silent=TRUE)


# ------------------------------------------ #











