Loading transfer_service/db_connector.py +12 −0 Original line number Diff line number Diff line import json import psycopg2 import sys Loading Loading @@ -29,6 +30,12 @@ class DbConnector(object): self.cursor.close() self.conn.close() def insertJob(self, jobObj): if self.conn: self.cursor.execute("INSERT INTO job(job_id, owner_id, job_type, phase, start_time, end_time, job_info, results) VALUES (%s, %s, %s, %s, %s, %s, %s, %s);", (jobObj.jobId, jobObj.ownerId, jobObj.type, jobObj.phase, jobObj.startTime, jobObj.endTime, json.dumps(jobObj.jobInfo), json.dumps(jobObj.results),)) self.conn.commit() def insertNode(self, node, parentOSPath): if self.conn: out = open("db_connector_log.txt", "a") Loading @@ -50,6 +57,11 @@ class DbConnector(object): def selectNode(self): pass def getJob(self, jobId): if self.conn: self.cursor.execute("SELECT * FROM job WHERE job_id = %s;", (jobId,)) return self.cursor.fetchone()[0] def getRapId(self, username): if self.conn: self.cursor.execute("SELECT rap_id FROM Users WHERE user_name = %s;", (username,)) Loading Loading
transfer_service/db_connector.py +12 −0 Original line number Diff line number Diff line import json import psycopg2 import sys Loading Loading @@ -29,6 +30,12 @@ class DbConnector(object): self.cursor.close() self.conn.close() def insertJob(self, jobObj): if self.conn: self.cursor.execute("INSERT INTO job(job_id, owner_id, job_type, phase, start_time, end_time, job_info, results) VALUES (%s, %s, %s, %s, %s, %s, %s, %s);", (jobObj.jobId, jobObj.ownerId, jobObj.type, jobObj.phase, jobObj.startTime, jobObj.endTime, json.dumps(jobObj.jobInfo), json.dumps(jobObj.results),)) self.conn.commit() def insertNode(self, node, parentOSPath): if self.conn: out = open("db_connector_log.txt", "a") Loading @@ -50,6 +57,11 @@ class DbConnector(object): def selectNode(self): pass def getJob(self, jobId): if self.conn: self.cursor.execute("SELECT * FROM job WHERE job_id = %s;", (jobId,)) return self.cursor.fetchone()[0] def getRapId(self, username): if self.conn: self.cursor.execute("SELECT rap_id FROM Users WHERE user_name = %s;", (username,)) Loading