Beispiel #1
0
 def update_tuple_hdfs(self, local_path, hdfs_chk):
     dic = {
         self.TIME_HDFS: asstr('datetime("now")', qmark=''),
         self.CHK_HDFS: asstr(hdfs_chk)
     }
     self.update_tuple(self.LOC, local_path,
                       dic)  # update by local path, todo: create index
Beispiel #2
0
 def check_table_exists(self):  # todo: check error
     cmd = "SELECT name FROM sqlite_master WHERE type='table' AND name=%s" % asstr(
         self.TABLE_NAME)
     conn = self.create_connection()
     c = conn.cursor()
     ret = len(c.execute(cmd).fetchall()) > 0
     conn.close()
     return ret
Beispiel #3
0
 def get_val_by_rem_path(self, col, rem_path):  # todo: check error handling
     conn = self.create_connection()
     c = conn.cursor()
     cmd = "SELECT %s FROM %s WHERE %s=%s" % (col, self.TABLE_NAME,
                                              self.HDFS, asstr(rem_path))
     c.execute(cmd)
     ret = c.fetchall()  # returns a list of tuples
     conn.close()
     try:
         result = ret[0][0]
         return result
     except IndexError:
         print("Remote path " + rem_path + " does not exist in the db")
         return None
Beispiel #4
0
 def insert_tuple_local(self, loc, rem, loc_chk, type_loc):
     """
     When a file is created locally
     :param loc: local path
     :param rem: remote path
     :param loc_chk: checksum of file copy locally
     :param type_loc: the type of the file locally ('dir', 'file' or 'link')
     :return:
     """
     dic = {
         self.LOC: asstr(loc),
         self.HDFS: asstr(rem),
         self.TIME_LOC: asstr('datetime("now")', qmark=''),
         self.TIME_HDFS: asstr(None),
         self.CHK_LOC: asstr(loc_chk),
         self.CHK_HDFS: asstr(None),
         self.TYPE_LOC: asstr(type_loc)
     }
     self.insert_tuple(dic)
Beispiel #5
0
 def update_tuple_local(self, local_path, loc_chk):
     dic = {
         self.TIME_LOC: asstr('datetime("now")', qmark=''),
         self.CHK_LOC: asstr(loc_chk)
     }
     self.update_tuple(self.LOC, local_path, dic)