           deferred.reject error
   deferred.promise
 
-mysqlConnect = (config) ->
+mysqlConnect = (mysqlConfig, config) ->
   deferred = Q.defer()
   console.log "connecting to MySQL..."
   connectWatch = durations.stopwatch().start()
-  connection = mysql.mysql.createConnection config
+  connection = mysql.mysql.createConnection mysqlConfig
   connection.connect (error) ->
     if error
       console.log "Error connecting to MySQL:", error, "\nStack:\n", error.stack

    database: config.database
  console.log "Connecting to database:\n'#{JSON.stringify(myCfg)}'"

  mysqlConnect myCfg
  .then (context) ->
    context.watch = durations.stopwatch().start()
    console.log "Ready to query MySQL."

  deferred.promise

# Connect to the database at the specified URI 
pgConnect = (uri, config) ->
  deferred = Q.defer()
  console.log "connecting to PostgreSQL..."
  connectWatch = durations.stopwatch().start()
