예제 #1
0
def getPictureInfo(column: str, value: str) -> bool:
    sql(TypicalWhereSelect.format("*", picturesTable, column, value))
    tempRes = instance.use_result()
    if tempRes.fetch_row():
        return True
    else:
        return False
예제 #2
0
def countUserPicturesByName(Name: str, UserID: str) -> int:
    """Deletes picture from database by Name"""
    sql("select count(*) from {} where {} = '{}' group by {} having {} '{}'" \
        .format(picturesTable, USER_ID_COL, UserID, PICTURE_NAME_COL, PICTURE_NAME_COL, Name))
    tempRes = instance.use_result()
    res = int(tempRes.fetch_row()[0][0])
    return res
예제 #3
0
def getLastPictureS3KeybyUserID(userID: int) -> str:
    """Find last picture belonging to user"""
    sql("select {} from {} where {} = '{}' order by {} desc" \
        .format(KEY_IN_S3_COL, picturesTable, USER_ID_COL, str(userID), ID_COL))
    tempRes = instance.use_result()
    res = str(tempRes.fetch_row()[0][0])[
        2:-1]  # substring to make b'PartYouNeed' returned by query PartYouNeed
    return res
예제 #4
0
def getPubic(ID: str) -> str:
    """Check if picture is public """
    sql(
        TypicalWhereSelect.format(PRIVATE_POLICY_VOL, picturesTable, ID_COL,
                                  ID))
    tempRes = instance.use_result()
    res = str(tempRes.fetch_row()[0][0])
    return res
예제 #5
0
def getListOfUserS3Keys(userID: str):
    """Return list of picture S3 keys"""
    sql(
        TypicalWhereSelect.format(KEY_IN_S3_COL, picturesTable, USER_ID_COL,
                                  userID))
    tempRes = instance.use_result()
    output = []
    for x in tempRes.fetch_row(0):
        output.append(str(x[0])[2:-1])
    return output
예제 #6
0
def getOwnerNamebyPictureID(ID: str) -> str:
    """ Finds picture's owner Name"""
    sql(TypicalWhereSelect.format(USER_NAME_COL, picturesTable, ID_COL, ID))
    tempRes = instance.use_result()
    res = str(tempRes.fetch_row()[0][0])[2:-1]
    return res
예제 #7
0
def getIDbyUserID(UserID: str) -> str:
    """ Finds picture's ID corresponding to user """
    sql(TypicalWhereSelect.format(ID_COL, picturesTable, USER_ID_COL, UserID))
    tempRes = instance.use_result()
    res = str(tempRes.fetch_row()[0][0])
    return res
예제 #8
0
def getIDbyS3Key(Key: str) -> str:
    """ Finds ID corresponding to S3_key """
    sql(TypicalWhereSelect.format(ID_COL, picturesTable, KEY_IN_S3_COL, Key))
    tempRes = instance.use_result()
    res = str(tempRes.fetch_row()[0][0])
    return res
예제 #9
0
def getS3KeybyID(ID: str) -> str:
    """ Return picture by ID"""
    sql(TypicalWhereSelect.format(KEY_IN_S3_COL, picturesTable, ID_COL, ID))
    tempRes = instance.use_result()
    res = str(tempRes.fetch_row()[0][0])[2:-1]
    return res
예제 #10
0
def getStringOfUserPictures(userID: str) -> str:
    """Return picture IDs separated by comma"""
    sql(TypicalWhereSelect.format(ID_COL, picturesTable, USER_ID_COL, userID))
    tempRes = instance.use_result()
    output = ", ".join([str(x[0]) for x in tempRes.fetch_row(0)])
    return output