Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm using demo from facebook's tornado

But I don't want to use MySQL and trying to replace it with PG So I went ahead and modified like this :

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

and

        # 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)

But app just hangs when I run it, how to properly migrate it to PG?

Actually I get error after some time:

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

Why is it connecting to MySQL?

share|improve this question
Check lines 62 and 63 of the script. – ypercube Dec 1 '12 at 17:29
But probably this won't be enough either. Check the REAME file: This demo is a simple blogging engine that uses MySQL to store posts and Google Accounts for author authentication. Since it depends on MySQL, you need to set up MySQL and the database schema for the demo to run. – ypercube Dec 1 '12 at 17:32
I just replaced my/pg is that wrong? – Jalil Dec 1 '12 at 17:41
1  
In short, that script is using "torndb" module, check that it has an import torndb and the error is after you have defined in lines 61-63 torndb.Connection(). See the Source code for torndb, it only uses MySQL, no Postgres. You have to rewrite that part (the whole torndb module, probably creating a new "torndbpostgres" module) to connect to Postgres instead of MySQL. – ypercube Dec 1 '12 at 21:12
The question is the same as on stackoverflow stackoverflow.com/questions/13661636/tornado-and-postgresql. @Jalil look at my answer there I edited it some time ago and maybe you need postgresql wrapper like momoko. – sufleR Dec 1 '12 at 23:58
show 2 more comments

closed as off topic by Mark Storey-Smith, Jack Douglas Dec 2 '12 at 9:03

Questions on Database Administrators Stack Exchange are expected to relate to database administration within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.