Ok, I thought you meant you were running some script manually. I guess "running the script" means "logging into RoundCube."
When you say, "DB Config," are you referring to the value of the mail_host column in the users table? This is populated based on the 'default_host' value in your configuration file. You should be able to define that configuration value to be the hostname of the IMAP server (which should be equivalent to localhost if you're running the web server on the same machine as the IMAP server).