def find_by_name(self, name): connection = self.get_connection() cursor = connection.cursor() statement = Helper.statement("select * from queues where name={}", name) cursor.execute(statement) result = Helper.cursor_to_json(cursor) if len(result) == 0: return None return result[0]
def insert(self, message): connection = self.get_connection() cursor = connection.cursor() statement = Helper.statement("insert into log(logtype_code, job_name, package_name, method_name, message, format_error_backtrace) values ({},{},{},{},{},{})", message['logtype_code'], message['job_name'], message['package_name'], message['method_name'], message['message'], message['backtrace']) cursor.execute(statement) message['id'] = cursor.lastrowid connection.commit() return message
def next(self, queue): connection = self.get_connection() cursor = connection.cursor() tablename = queue['tablename'] statement = "select * from " + tablename + " where state='READY' order by created_at" cursor.execute(statement) result = Helper.cursor_to_json(cursor) if len(result) == 0: return None return result[0]
def find_by_hashcode(self, hashcode): connection = self.get_connection() cursor = connection.cursor() m = {} m['hashcode'] = hashcode statement = "select * from users where hashcode=:hashcode" statement, parameters = self.statement(statement, m) cursor.execute(statement, parameters) result = Helper.cursor_to_json(cursor) cursor.close() if len(result) == 0: return None return result[0]
def list_by_job_name(self, job_name): connection = self.get_connection() cursor = connection.cursor() statement = "select * from log where job_name=:job_name" m = {} m['job_name'] = job_name statement, parameters = self.statement(statement, m) cursor.execute(statement, parameters) result = Helper.cursor_to_json(cursor) if len(result) == 0: return None return result
def find_by_id(self, id): connection = self.get_connection() cursor = connection.cursor() m = {} m['id'] = id statement = "select * from sessions where id=:id" statement, parameters = self.statement(statement, m) print statement, parameters cursor.execute(statement, parameters) result = Helper.cursor_to_json(cursor) cursor.close() if len(result) == 0: return None return result[0]
def find_by_name(self, content): logger = Logger(self) connection = self.get_connection() cursor = connection.cursor() statement = "select * from commands where name=:name and environment=:environment" m = {} m['name'] = content['command'] m['environment'] = content['environment'] statement, parameters = self.statement(statement, m) cursor.execute(statement, parameters) result = Helper.cursor_to_json(cursor) if len(result) == 0: return None return result[0]
def list(self): connection = self.get_connection() cursor = connection.cursor() cursor.execute("select * from users") return Helper.cursor_to_json(cursor)
def list_active(self): connection = self.get_connection() cursor = connection.cursor() cursor.execute("select * from queues where active=1") return Helper.cursor_to_json(cursor)