Exemple #1
0
class SiafuProtocol(LineReceiver):

    def __init__(self, addr):
        self.addr = addr
        self.siafu = Siafu(settings.DATABASE)

    def connectionMade(self):
        logging.info("new connection: {0}".format(self.addr))
        self.sendLine("Connected, Send it")

    def connectionLost(self, reason):
        logging.info("connection lost: {0}".format(self.addr))

    def lineReceived(self, line):
        logging.info("Received line: {0} from {1}".format(
            line, self.addr))
        try:
            result = self.siafu.process_sql(line)
            self.sendLine(result)
        except SiafuSyntaxError, sse:
            logging.exception(sse)
            self.sendLine("Error: {0}".format(sse.__unicode__()))
        except SiafuError, se:
            logging.exception(se)
            self.sendLine("Error: {0}".format(se.__unicode__()))
Exemple #2
0
 def __init__(self, addr):
     self.addr = addr
     self.siafu = Siafu(settings.DATABASE)