def query_InvoiceandBilling()

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


def query_InvoiceandBilling(tablename,value):

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

    if(value.startswith("I#")):
        KCE = Key('PK').eq(value)
        response = table.query(KeyConditionExpression=KCE)
        return(response['Items'])

    if(value.startswith("B#") or value.startswith("C#")):
        print("\n ============================================================================================================================== \n")
        print("\n No records found for {}. Please use the query_index_invoiceandbilling.py script for querying Customer and Billing details.\n".format(value))
        print("\n ============================================================================================================================== \n")
        exit()