title: tornado and postgresql
body: <p>I'm using demo from <a href="https://github.com/facebook/tornado/blob/master/demos/blog/blog.py" rel="nofollow">facebook's tornado</a></p>
  
  <p>But I don't want to use MySQL and trying to replace it with PG
  So I went ahead and modified like this :</p>
  
  <pre><code>define("port", default=8888, help="run on the given port", type=int)
  define("pgsql_host", default="127.0.0.1:5432", help="blog database host")
  define("pgsql_database", default="pgdb", help="blog database name")
  define("pgsql_user", default="admin", help="blog database user")
  define("pgsql_password", default="pgpass", help="blog database password")
  </code></pre>
  
  <p>and</p>
  
  <pre><code>        # Have one global connection to the blog DB across all handlers
      self.db = tornado.database.Connection(
          host=options.pgsql_host, database=options.pgsql_database,
          user=options.pgsql_user, password=options.pgsql_password)
  </code></pre>
  
  <p>But app just hangs when I run it, how to properly migrate it to PG?</p>
  
  <p>Actually I get error after some time:</p>
  
  <pre><code>    Traceback (most recent call last):
    File "/usr/local/lib/python2.7/dist-packages/tornado-2.4.1-py2.7.egg/tornado/database.py", line 84, in __init__
      self.reconnect()
    File "/usr/local/lib/python2.7/dist-packages/tornado-2.4.1-py2.7.egg/tornado/database.py", line 101, in reconnect
      self._db = MySQLdb.connect(**self._db_args)
    File "/usr/lib/pymodules/python2.7/MySQLdb/__init__.py", line 81, in Connect
      return Connection(*args, **kwargs)
    File "/usr/lib/pymodules/python2.7/MySQLdb/connections.py", line 187, in __init__
      super(Connection, self).__init__(*args, **kwargs2)
  OperationalError: (2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0")
  </code></pre>
  
  <p>Why is it connecting to MySQL?</p>