Source

txMysql / bin / tmysqlc

Full commit
#!/usr/bin/env python
# -*- mode: python -*-
"""tmysqlc - twisted mysql client

"""

# standard lib
import sys

# 3rd party
from twisted.python import filepath
from twisted.python import log
from twisted.internet import reactor

# 1st party
from txmysql import adbapi
from txmysql import protocol
from txmysql import settings


def shutdown(_):
    reactor.stop()

def run(result):
    return pool.runQuery("select 1")

#factory = protocol.MysqlProtocolFactory(
#    settings.USERNAME,
#    settings.PASSWORD
#)
#d = factory.getDeferred()
#d.addErrback(shutdown)
#d.addCallback(runQuery)   
#reactor.connectTCP(settings.HOSTNAME, settings.PORT, factory)
#reactor.run()

pool = adbapi.ConnectionPool(settings.HOSTNAME, settings.PORT,
                   settings.USERNAME, settings.PASSWORD,
                   size=2)
dl = pool.start()
dl.addCallback(run)
dl.addErrback(log.err)
dl.addCallback(shutdown)
reactor.run()