Reformat SQL queries for readability

SQL queries are somewhat reformatted for readability.

Also go from Python string formatting to using basic parameterization
offered by MySQLdb.
Introduce optparse

Rely on optparse for getting options and arguments instead of directly
accessing sys.argv. This doesn't change much now but it's easier to add
options going forward.
Print error messages to stderr
Remove dependency on ipaddr

Instead of using the convenient functions of the ipaddr module to check
for a valid IP address, we build our own IP checker using the sockets
module which is included with Python by default, thus removing an
external dependency.
Add support for common PoPs

Rewrote a whole bunch of stuff along the way :)
Restructure code for common IXP

Let SQL do the joining instead of doing it manually with Python code.
Less code. Faster. Better. Harder. Stronger.
Remove unused variables
Fix SQL query for #ASN > 2
Merge pull request #1 from plajjan/master

Add support for common facilities & lots of restructuring