Skip to content

Instantly share code, notes, and snippets.

@InPermutation
Created March 30, 2012 21:07
Show Gist options
  • Select an option

  • Save InPermutation/2255010 to your computer and use it in GitHub Desktop.

Select an option

Save InPermutation/2255010 to your computer and use it in GitHub Desktop.
Get a config for https://github.com/felixge/node-mysql from heroku DATABASE_URL
function mysqlConfigFromEnvironment (){
var dbUrl = process.env.DATABASE_URL;
var parsed = url.parse(dbUrl);
return {
host: parsed.host,
port: parsed.port || 3306,
user: parsed.auth.split(':')[0],
password: parsed.auth.split(":")[1]
};
};
var client = mysql.createClient(mysqlConfigFromEnvironment());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment