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

    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."

  uri = "postgres://#{config.user}:#{config.password}@#{config.host}:#{config.port}/#{config.database}"
  console.log "Connecting to URI '#{uri}'"

  pgConnect uri, config
  .then (context) ->
    context.watch = durations.stopwatch().start()
    console.log "Ready to query PostgreSQL."
