Пример #1
0
 def find_user_by_username(username):  # Returns a User Object.
     db = Database()
     db.connect()
     sql = "SELECT * from user where username = '******'".format(username)
     row = db.query(sql)
     row = row[0]
     newUser = User()
     newUser.set_id(row['id'])
     newUser.set_username(row['username'])
     newUser.set_password(row['password'])
     newUser.set_email(row['email'])
     return newUser
Пример #2
0
 def new_UserObject(id):
     db = Database()
     db.connect()
     sql = "SELECT * from user WHERE id = {0}".format(id)
     row = db.query(sql)
     row = row[0]
     newUser = User()
     newUser.set_id(row['id'])
     newUser.set_username(row['username'])
     newUser.set_password(row['password'])
     newUser.set_email(row['email'])
     return newUser
Пример #3
0
def main():
    load_dotenv()
    db = Database()
    db.connect()
    amazonScraper = AmazonScraper()
    neweggScraper = NeweggScraper()
    logger = Logger('Create New Product')
    product = {}
    # logger.info("What is the URL of the product?")
    productURL = input("What is the URL of the product? ")

    isUnique = db.checkUniqueURL(productURL)

    if not isUnique:
        logger.error('ProductURL is aleady setup for scraping')
        return

    # logger.info(
    #     "What is the name of the product (this is just the name you want to give it)?")
    productName = input(
        "What is the name of the product (this is just the name you want to give it)? "
    )
    if 'amazon' in productURL:
        price = amazonScraper.getPrice(productURL)
    elif 'newegg' in productURL:
        price = neweggScraper.getPrice(productURL)
    product["ProductURL"] = productURL
    product['ProductName'] = productName
    product["LatestPrice"] = price
    product["LowestPriceAllTime"] = price
    product["LowestPriceAllTimeDate"] = datetime.date.today()
    product["LowestPriceMonth"] = price
    product["LowestPriceMonthDate"] = datetime.date.today()
    product["LowestPriceWeek"] = price
    product["LowestPriceWeekDate"] = datetime.date.today()
    product["LastDatePricePulled"] = datetime.date.today()

    db.insert(product)
    db.closeConnection()
import constants
from classes.card import Card
from classes.database import Database

# MENU OPTIONS SETUP
guest_options = ['1. Create an account', '2. Log into account', '0. Exit']
logged_in_options = [
    '1. Balance', '2. Add income', '3. Do transfer', '4. Close account',
    '5. Log out', '0. Exit'
]

# AUTHENTICATION SETUP
logged_in = -1
selected_option = None
db = Database()
db.connect()


def login():
    """Try and login with provided card data by searching card number and pin in the database.

    Returns:
        The card id if successful, -1 if otherwise.
    """
    card_number = str(input(constants.LOGIN_CARD_INPUT))
    card_pin = str(input(constants.LOGIN_PIN_INPUT))
    # if found, the response contains the card data (id, number, pin, balance)
    response = db.get_card_data_by_number(card_number)

    if not response:
        return -1