def query_InvoiceandBilling()

in design-patterns/query_index_invoiceandbilling.py [0:0]


def query_InvoiceandBilling(tablename,value):

    dynamodb = boto3.resource('dynamodb')
    table = dynamodb.Table(tablename)

    if(value.startswith("I#")):
        print("\n =============================================================================================================== \n")
        print("!! No records found for {}. Pleaes use the query_invoiceandbilling.py for Invoice details.".format(value))
        print("\n =============================================================================================================== \n")
        exit()

    if(value.startswith("C#")):
        KCE = Key('SK').eq(value)
        response = table.query(IndexName='GSI_1',KeyConditionExpression=KCE)

    elif(value.startswith("B#")):
        KCE = Key('SK').eq(value)
        response = table.query(IndexName='GSI_1',KeyConditionExpression=KCE)
    return(response['Items'])