Exemplo n.º 1
0
def split_vo(dialect, column, return_vo=False):
    """
    Utility script for extracting the name and VO from InternalAccount/Scope entries in the DB.

    :param dialect:   The dialct of the DB.
    :param column:    The column to perform the operation on.
    :param return_vo: If True, return the 3 characters after the '@' symbol, else return everything before it.
    """
    if dialect == 'postgresql':
        if return_vo:
            return func.split_part(column, bindparam('split_character'), bindparam('int_2'))
        else:
            return func.split_part(column, bindparam('split_character'), bindparam('int_1'))
    else:
        # Dialects other than postgresql haven't been tested
        i = func.INSTR(column, bindparam('split_character'))
        if return_vo:
            return func.SUBSTR(column, i + 1)
        else:
            return func.SUBSTR(column, bindparam('int_1'), i - 1)
Exemplo n.º 2
0
 def re_volume(x):
     return {
         Volume.IDS:  func.INSTR(','+",".join(sid)+',',func.CONCAT(',',Goods.id,',')),
         Volume.PRICE: Goods.price,
     }.get(x, 0)