Exemplo n.º 1
0
def get_customer_info(customer_id):

    with connection.cursor() as cur:
        cur.execute(
            "SELECT  NAME , EMAIL , USERNAME , GENDER , STREET , ZIPCODE , CITY , COUNTRY , "
            "PHONE_NUM , ISVERIFIED FROM CUSTOMER WHERE customerId = %s",
            [customer_id])
        result = cur.fetchone()
        global customer
        customer = Customer(customer_id=customer_id,
                            name=result[0],
                            email=result[1],
                            username=result[2],
                            gender=result[3],
                            street=result[4],
                            zipcode=result[5],
                            city=result[6],
                            country=result[7],
                            phone=result[8],
                            isVerified=result[9])

        cur.execute(
            "SELECT  CARD_NUMBER , CARD_USERNAME , CARD_TYPE , CVC , EXPIRATION  FROM CREDIT_CARD "
            "WHERE customerId = %s", [customer_id])
        result = cur.fetchone()

        if result:

            customer.card_number = result[0]
            customer.card_username = result[1]
            customer.card_type = result[2]
            customer.cvc = result[3]
            customer.expiration = str(result[4].date())

        cur.execute(
            "SELECT  PHONE_NUMBER , SERVICE_PROVIDER , CUSTOMERID FROM MOBILE_BANKING "
            "WHERE customerId = %s", [customer_id])
        result = cur.fetchone()
        if result:
            customer.mob_banking_phone_number = result[0]
            customer.mob_banking_service_provider = result[1]