Ejemplo n.º 1
0
def reset_domain_data():
    domains = db_session.query(Domain).all()
    for d in domains:
        db_session.delete(d)
    db_session.commit()
    drop_all()
    return "success"
Ejemplo n.º 2
0
def remove_domain():
    domain = db_session.query(Domain).filter_by(
        domain_name=request.form['domain_name']).one()
    db_session.delete(domain)
    db_session.commit()
    db_session.close()
    return "successfully deleted domain %s" % request.form['domain_name']
Ejemplo n.º 3
0
def add_domain():
    try:
        if request.form['active'] == 'true':
            active = True
        else:
            active = False
        domain = Domain(domain_name=request.form['domain_name'],
                        grade=request.form['grade'],
                        last_updated=request.form['last_updated'],
                        status=request.form['status'],
                        active=active)

        db_session.add(domain)
        db_session.commit()
        db_session.close()
        return "success!"
    except IntegrityError:
        db_session.rollback()
        # Domain already exists so just update the current one.
        domain = db_session.query(Domain)\
            .filter_by(domain_name=request.form['domain_name']).one()

        domain.grade = request.form['grade']
        domain.last_updated = request.form['last_updated']
        domain.status = request.form['status']
        domain.active = request.form['active']
        db_session.commit()
        db_session.close()
        return "updated previous host %s" % request.form['domain_name']
Ejemplo n.º 4
0
def get_or_create_movie_data(RT_url, movie_title):
    # gets movie from database if exists, otherwise commits new movie to database and returns it
    movie_db = Movie.query.filter(Movie.RT_url == RT_url).first()
    if movie_db == None:
        movie = RTMovie(RT_url)
        movie_general_info = movie.get_general_info()
        movie_db = Movie(
            RT_url,
            # add actual imdb_url later
            None,
            movie_title,
            movie_general_info['rating'],
            movie_general_info['length'],
            movie.get_img(),
            # add actual imdb_score later
            None,
            movie.get_RT_score(),
            movie.get_synopsis())
        db_session.add(movie_db)
        db_session.commit()

        for genre in movie_general_info['genre']:
            db_session.add(Genre(movie_db.id, genre))
        for cast in movie.get_cast():
            db_session.add(Cast(movie_db.id, cast))
        for director in movie_general_info['director']:
            db_session.add(Director(movie_db.id, director))
        db_session.commit()
    return movie_db
Ejemplo n.º 5
0
def scrape_and_commit_zip(zipcode, shelter_ids):
    from server.database import db_session
    dog_jsons = fetch_dogs_in_zip(zipcode, shelter_ids)

    while not shelter_ids.empty():
        shelter_id = shelter_ids.get()
        print(shelter_id)
        shelter_json = fetch_shelter_html_hack(shelter_id)
        if shelter_json.get("zipcode") is None:
            api_shelter_json = fetch_shelter_info(shelter_id)
            if api_shelter_json is not None:
                shelter_json["zipcode"] = int(api_shelter_json["zipcode"])
        shelter = make_shelter(shelter_json)
        db_session.add(shelter)

    db_session.add_all(
        [make_dog_and_breeds(dog_json) for dog_json in dog_jsons])

    db_session.commit()

    for dog_json in dog_jsons:
        print("{id}: {name}".format(**dog_json))

    parks = fetch_parks_in_zip(zipcode)
    db_session.add_all(parks)
    db_session.commit()

    for park in parks:
        print(park)
Ejemplo n.º 6
0
def add_test_domains():
    domains = []
    domains.append(
        Domain(domain_name='example_one.ru',
               grade='A+',
               last_updated=1491918400000,
               status='OK',
               active=True))
    domains.append(
        Domain(domain_name='example_two.ru',
               grade='F',
               last_updated=1491918400000,
               status='OK',
               active=True))
    domains.append(
        Domain(domain_name='example_three.ru',
               grade='B',
               last_updated=1491918400000,
               status='OK',
               active=True))
    domains.append(
        Domain(domain_name='example_disabled.ru',
               grade='A+',
               last_updated=1491918400000,
               status='OK',
               active=False))
    db_session.add_all(domains)
    db_session.commit()
    return "success"
Ejemplo n.º 7
0
def user():
    # search for the user in our db using their github 
    user = db_session.query(models.User) \
        .filter(models.User.login == g.user['login']) \
        .first()

    # if the user doesn't exist, create a new one!
    if not user:
        new_user = models.User(g.user['login'])
        db_session.add(new_user)
        db_session.commit()

        user = new_user
    
    # just for fun, keeping track of a users last activity!
    user.last_activity = datetime.now()
    
    # don't forget to save changes after making modifications to an entry in the db.
    db_session.commit()

    # return the user data
    num_happy, num_sad = utils.getCounts()
    return jsonify({
        'login': g.user['login'],
        'name': g.user['name'],
        'avatar_url': g.user['avatar_url'],
        'is_happy': user.feeling == models.FeelingStatus.HAPPY,
        'num_happy': num_happy,
        'num_sad': num_sad
    })
Ejemplo n.º 8
0
def insert_initial_user(*args, **kwargs):
    """
        Example function that listens for the after_create event for a 
        table. In this case, it's adding an initial pre-determined value
        to the User table.
    """
    user = User("Yohlo")
    db_session.add(user)
    db_session.commit()
Ejemplo n.º 9
0
def update_password_for_user(
    user_id: int,
    password: str,
) -> bool:
    """Update the password for a user"""
    db_session.update(User, ).where(User.id == user_id, ).values(
        password == generate_password_hash(password), )
    db_session.commit()
    return True
Ejemplo n.º 10
0
def commit_theater_info(theater_url):
    theater_info = AMCTheaters(theater_url).get_theater_info()
    if theater_info != None:
        theater_db = Theater(theater_info['url'], theater_info['name'],
                             theater_info['street'], theater_info['city'],
                             theater_info['state'], theater_info['zipCode'])
        print "Committing %s info" % (theater_db.name)
        db_session.add(theater_db)
        db_session.commit()
Ejemplo n.º 11
0
def update_prod_theaters():
    start = time.time()
    Showing.query.delete()
    Theater.query.delete()
    db_session.commit()

    commit_all_theaters()

    end = time.time()
    print 'Updating theaters took %f seconds' % (end - start)
Ejemplo n.º 12
0
def update_expense(info, id=None, sub_category_id=None, item=None, unit=None,quantity=None, provider=None, price=None, category_id=None, user_id=None):
    query = Expense.get_query(info)
    if id:
        to_update = {"sub_category_id": sub_category_id, "item": item, "unit": unit, "quantity": quantity, "provider": provider, "price": price, "category_id": category_id, "user_id": user_id}
        query.\
            filter(ExpenseModel.id == id).\
            update({k: v for k, v in to_update.items() if v is not None})
        db_session.commit()
    query = query.filter(ExpenseModel.id == id)
    return query.first()
def update_sub_category(info, id=None, category_id=None, sub_category_name=None, user_id=None):
    query = Sub_Category.get_query(info)
    if id:
        to_update = {"category_id": category_id, "sub_category_name": sub_category_name, "user_id": user_id}
        query.\
            filter(Sub_CategoryModel.id == id).\
            update({k: v for k, v in to_update.items() if v is not None})
        db_session.commit()
    query = query.filter(Sub_CategoryModel.id == id)
    return query.first()
Ejemplo n.º 14
0
def init_prod_db():
    # performs a full initialization of the entire production database after deleting all tables
    # added Base back into this function otherwise can't reinitialize database after deleting db file due to schema changes
    Base.metadata.create_all(bind=engine)
    update_prod_theaters()
    Genre.query.delete()
    Cast.query.delete()
    Director.query.delete()
    Movie.query.delete()
    db_session.commit()
    update_prod_showings()
Ejemplo n.º 15
0
def create_users():
    logins = ['alex', 'vova', 'alina']

    for login in logins:
        user = User(
            login=login, 
            email=login + '@mail.ru', 
            password = '******'
        )
        db_session.add(user)
    db_session.commit()
Ejemplo n.º 16
0
def delete_user(user_id: int) -> bool:
    """Delete a user from the database"""
    # Note: The returned value is the number of rows that were deleted
    # from the table
    result = User.query.filter(User.id == user_id, ).delete()

    if not result:
        return False

    db_session.commit()
    return True
Ejemplo n.º 17
0
def update_prod_showings():
    # updates showings database and adds any new movies and related info to their appropriate databases using preexisting theater database info
    start = time.time()
    Showing.query.delete()
    db_session.commit()

    theaters = Theater.query.all()
    commit_all_showings(theaters)

    end = time.time()
    print 'Updating showings took %f seconds' % (end - start)
Ejemplo n.º 18
0
def create_games():
    for item in range(0,10):
        if item % 2 == 0:
            game = Game(
                creator_id=User.query.all()[0].id
            )
            db_session.add(game)
        else:
            game = Game(
                creator_id=User.query.all()[1].id
            )
            db_session.add(game)
    db_session.commit()
Ejemplo n.º 19
0
def commit_showing_info(showing_url, theater_db):
    showing_info = AMCShowingInfo(showing_url).get_showing_info()
    # will not commit to database if showing info section is not found when scraping
    if showing_info != None:
        RT_url = get_RT_url(showing_info['movie'])
        if RT_url != None:
            with lock:
                movie_db = get_or_create_movie_data(RT_url,
                                                    showing_info['movie'])
                for time in showing_info['times']:
                    print "Committing %s" % (showing_url)
                    db_session.add(
                        Showing(movie_db.id, theater_db.id, showing_url,
                                showing_info['date'], time))
                    db_session.commit()
Ejemplo n.º 20
0
def follow_user(
    follower: int,
    followee: int,
) -> bool:
    """Store the follows relationship in the database"""
    follows = Follows(
        follower=follower,
        followee=followee,
    )
    try:
        db_session.add(follows)
        db_session.commit()
    except IntegrityError as e:
        raise DuplicateFollowException from e

    return True
Ejemplo n.º 21
0
def register_user(
    first_name: str,
    last_name: str,
    username: str,
    password: str,
) -> User:
    """Store user information in the database"""
    user = User(
        first_name=first_name,
        last_name=last_name,
        username=username,
        password=generate_password_hash(password),
    )
    try:
        db_session.add(user)
        db_session.commit()
    except IntegrityError as e:
        raise UserAlreadyExistsException from e
    else:
        return user
Ejemplo n.º 22
0
def toggle_happiness():
    user = db_session.query(models.User) \
        .filter(models.User.login == g.user['login']) \
        .first()
    
    # instead of creating a new user in this case, 
    # simply just 404. User creation should be handled by the /user request.
    if not user: return "User not found!", 404

    user.feeling = models.FeelingStatus.HAPPY if user.feeling == models.FeelingStatus.SAD else models.FeelingStatus.SAD
    user.last_activity = datetime.now()

    db_session.commit()

    num_happy, num_sad = utils.getCounts()
    return jsonify({
        'is_happy': user.feeling == models.FeelingStatus.HAPPY,
        'num_happy': num_happy,
        'num_sad': num_sad
    })
Ejemplo n.º 23
0
def add_equity_order(
    user_id: int,
    ticker: str,
    order_type: OrderType,
    quantity: float,
    price: float,
) -> bool:
    """Store the equity order in the database"""
    ticker_info = get_ticker_symbol(ticker)
    if not ticker_info:
        raise ValueError("Invalid ticker symbol")

    user_transaction = EquityOrder(
        user_id=user_id,
        ticker_id=ticker_info.id,
        order_type=order_type,
        quantity=quantity,
        price=price,
    )
    db_session.add(user_transaction)
    db_session.commit()
    return user_transaction
Ejemplo n.º 24
0
def register_ticker_symbol(exchange_id: int, ticker: str, company_name: str,) -> Ticker:
    """Store the ticker information in the database"""
    ticker = Ticker(exchange_id=exchange_id, ticker=ticker, company_name=company_name)
    db_session.add(ticker)
    db_session.commit()
    return ticker
Ejemplo n.º 25
0
def init_test_db():
    Base.metadata.create_all(bind=engine)
    from server.database import db_session
    from server.models import Movie, Theater, Showing, Genre, Cast, Director

    Movie.query.delete()
    Theater.query.delete()
    Showing.query.delete()
    Genre.query.delete()
    Cast.query.delete()
    Director.query.delete()

    movie_one = Movie(
        'https://www.rottentomatoes.com/m/the_dark_knight',
        'https://www.imdb.com/title/tt0468569/', 'The Dark Knight', 'PG-13',
        152, 'https://upload.wikimedia.org/wikipedia/en/8/8a/Dark_Knight.jpg',
        9.0, 94,
        "Christopher Nolan steps back into the director's chair for this sequel to Batman Begins, which finds the titular superhero coming face to face with his greatest nemesis -- the dreaded Joker. Christian Bale returns to the role of Batman, Maggie Gyllenhaal takes over the role of Rachel Dawes (played by Katie Holmes in Batman Begins), and Brokeback Mountain star Heath Ledger dons the ghoulishly gleeful Joker makeup previously worn by Jack Nicholson and Cesar Romero. Just as it begins to appear as if Batman, Lt. James Gordon (Gary Oldman), and District Attorney Harvey Dent (Aaron Eckhart) are making headway in their tireless battle against the criminal element, a maniacal, wisecracking fiend plunges the streets of Gotham City into complete chaos. ~ Jason Buchanan, Rovi"
    )

    movie_two = Movie(
        'https://www.rottentomatoes.com/m/500_days_of_summer',
        'https://www.imdb.com/title/tt1022603/', '500 Days of Summer', 'PG-13',
        95,
        'https://upload.wikimedia.org/wikipedia/en/d/d1/Five_hundred_days_of_summer.jpg',
        7.7, 85,
        "Joseph Gordon-Levitt and Zooey Deschanel star in director Marc Webb's wry, nonlinear romantic comedy about a man who falls head over heels for a woman who doesn't believe in love. Tom (Gordon-Levitt) is an aspiring architect who currently earns his living as a greeting card writer. Upon encountering his boss' beautiful new secretary, Summer (Deschanel), Tom discovers that the pair have plenty in common despite the fact that she's seemingly out of his league; for starters, they both love the Smiths, and they're both fans of surrealist artist Magritte. Before long Tom is smitten. All he can think about is Summer. Tom believes deeply in the concept of soul mates, and he's finally found his. Unfortunately for Tom, Summer sees true love as the stuff of fairy tales, and isn't looking for romance. Undaunted and undeterred by his breezy lover's casual stance on relationships, Tom summons all of his might and courage to pursue Summer and convince her that their love is real. ~ Jason Buchanan, Rovi"
    )

    movie_three = Movie(
        'https://www.rottentomatoes.com/m/spirited_away',
        'https://www.imdb.com/title/tt0245429/', 'Spirited Away', 'PG', 124,
        'https://upload.wikimedia.org/wikipedia/en/d/db/Spirited_Away_Japanese_poster.png',
        8.6, 97,
        "Master animation director Hayao Miyazaki follows up on his record-breaking 1997 opus Princess Mononoke with this surreal Alice in Wonderland-like tale about a lost little girl. The film opens with ten-year-old Chihiro riding along during a family outing as her father races through remote country roads. When they come upon a blocked tunnel, her parents decide to have a look around -- even though Chihiro finds the place very creepy. When they pass through the tunnel, they discover an abandoned amusement park. As Chihiro's bad vibes continue, her parents discover an empty eatery that smells of fresh food. After her mother and father help themselves to some tasty purloined morsels, they turn into giant pigs. Chihiro understandably freaks out and flees. She learns that this very weird place, where all sorts of bizarre gods and monsters reside, is a holiday resort for the supernatural after their exhausting tour of duty in the human world. Soon after befriending a boy named Haku, Chihiro learns the rules of the land: one, she must work , as laziness of any kind is not tolerated; and two, she must take on the new moniker of Sen. If she forgets her real name, Haku tells her, then she will never be permitted to leave. ~ Jonathan Crow, Rovi"
    )

    movie_four = Movie(
        'https://www.rottentomatoes.com/m/the_grand_budapest_hotel',
        'https://www.imdb.com/title/tt2278388/', 'The Grand Budapest Hotel',
        'R', 99,
        'https://upload.wikimedia.org/wikipedia/en/1/1c/The_Grand_Budapest_Hotel.png',
        8.1, 91,
        "THE GRAND BUDAPEST HOTEL recounts the adventures of Gustave H, a legendary concierge at a famous European hotel between the wars, and Zero Moustafa, the lobby boy who becomes his most trusted friend. The story involves the theft and recovery of a priceless Renaissance painting and the battle for an enormous family fortune -- all against the back-drop ofa suddenly and dramatically changing Continent. (c) Fox Searchlight"
    )

    movie_five = Movie(
        'https://www.rottentomatoes.com/m/american_psycho',
        'https://www.imdb.com/title/tt0144084/', 'American Psycho', 'R', 97,
        'https://upload.wikimedia.org/wikipedia/en/0/0c/American_Psycho.png',
        7.6, 68,
        "Patrick Bateman is young, white, beautiful, ivy leagued, and indistinguishable from his Wall Street colleagues. Shielded by conformity, privilege, and wealth, Bateman is also the ultimate serial killer, roaming freely and fearlessly. His murderous impulses are fueled by zealous materialism and piercing envy when he discovers someone else has acquired more than he has. After a colleague presents a business card superior in ink and paper to his, Bateman's blood thirst sharpens, and he steps up his homicidal activities to a frenzied pitch. Hatchets fly, butcher knives chop, chainsaws rip, and surgical instruments mutilate-how far will Bateman go? How much can he get away with?"
    )

    movie_six = Movie(
        'https://www.rottentomatoes.com/m/alita_battle_angel',
        'https://www.imdb.com/title/tt0437086/', 'Alita: Battle Angel',
        'PG-13', 125,
        'https://resizing.flixster.com/dL-8X6XHhPBaA60t2zmquQzA6uI=/fit-in/200x296.2962962962963/v1.bTsxMjk4NTcxOTtqOzE3OTcwOzEyMDA7NDA1MDs2MDAw',
        7.6, 61,
        "From visionary filmmakers James Cameron (AVATAR) and Robert Rodriguez (SIN CITY), comes ALITA: BATTLE ANGEL, an epic adventure of hope and empowerment. When Alita (Rosa Salazar) awakens with no memory of who she is in a future world she does not recognize, she is taken in by Ido (Christoph Waltz), a compassionate doctor who realizes that somewhere in this abandoned cyborg shell is the heart and soul of a young woman with an extraordinary past. As Alita learns to navigate her new life and the treacherous streets of Iron City, Ido tries to shield her from her mysterious history while her street-smart new friend Hugo (Keean Johnson) offers instead to help trigger her memories. But it is only when the deadly and corrupt forces that run the city come after Alita that she discovers a clue to her past - she has unique fighting abilities that those in power will stop at nothing to control. If she can stay out of their grasp, she could be the key to saving her friends, her family and the world she's grown to love."
    )

    theater_one = Theater(
        'https://www.amctheatres.com/movie-theatres/seattle-tacoma/amc-pacific-place-11',
        'AMC Pacific Place 11', '600 Pine Street - Ste 400', 'Seattle',
        'Washington', 98101)
    theater_two = Theater(
        'https://www.amctheatres.com/movie-theatres/seattle-tacoma/amc-oak-tree-6',
        'AMC Oak Tree 6', '10006 Aurora Avenue N.', 'Seattle', 'Washington',
        98133)
    theater_three = Theater(
        'https://www.amctheatres.com/movie-theatres/seattle-tacoma/amc-seattle-10',
        'AMC Seattle 10', '4500 9th Ave Ne', 'Seattle', 'Washington', 98105)
    db_session.add_all([
        movie_one, movie_two, movie_three, movie_four, movie_five, movie_six,
        theater_one, theater_two, theater_three
    ])
    db_session.commit()
    db_session.add_all([
        Genre(movie_one.id, 'Action & Adventure'),
        Genre(movie_one.id, 'Drama'),
        Genre(movie_one.id, 'Science Fiction & Fantasy'),
        Cast(movie_one.id, 'Christian Bale'),
        Cast(movie_one.id, 'Heath Ledger'),
        Cast(movie_one.id, 'Aaron Eckhart'),
        Cast(movie_one.id, 'Maggie Gyllenhaal'),
        Cast(movie_one.id, 'Gary Oldman'),
        Cast(movie_one.id, 'Morgan Freeman'),
        Director(movie_one.id, 'Christopher Nolan'),
        Genre(movie_two.id, 'Comedy'),
        Genre(movie_two.id, 'Drama'),
        Genre(movie_two.id, 'Romance'),
        Cast(movie_two.id, 'Joseph Gordon-Levitt'),
        Cast(movie_two.id, 'Zooey Deschanel'),
        Cast(movie_two.id, 'Geoffrey Arend'),
        Cast(movie_two.id, 'Chloe Grace Moretz'),
        Cast(movie_two.id, 'Matthew Gray Gubler'),
        Cast(movie_two.id, 'Clark Gregg'),
        Director(movie_two.id, 'Marc Webb'),
        Genre(movie_three.id, 'Animation'),
        Genre(movie_three.id, 'Drama'),
        Genre(movie_three.id, 'Kids & Family'),
        Genre(movie_three.id, 'Science Fiction & Fantasy'),
        Cast(movie_three.id, 'Rumi Hiiragi'),
        Cast(movie_three.id, 'Miyu Irino'),
        Cast(movie_three.id, 'Mari Natsuki'),
        Cast(movie_three.id, 'Takashi Naito'),
        Cast(movie_three.id, 'Yasuko Sawaguchi'),
        Cast(movie_three.id, 'Tsunehiko Kamijo'),
        Director(movie_three.id, 'Hayao Miyazaki'),
        Genre(movie_four.id, 'Comedy'),
        Genre(movie_four.id, 'Drama'),
        Cast(movie_four.id, 'Ralph Fiennes'),
        Cast(movie_four.id, 'Tony Revolori'),
        Cast(movie_four.id, 'F. Murray Abraham'),
        Cast(movie_four.id, 'Edward Norton'),
        Cast(movie_four.id, 'Saoirse Ronan'),
        Cast(movie_four.id, 'Tilda Swinton'),
        Director(movie_four.id, 'Wes Anderson'),
        Genre(movie_five.id, 'Comedy'),
        Genre(movie_five.id, 'Drama'),
        Genre(movie_five.id, 'Horror'),
        Genre(movie_five.id, 'Mystery & Suspense'),
        Cast(movie_five.id, 'Christian Bale'),
        Cast(movie_five.id, 'Willem Dafoe'),
        Cast(movie_five.id, 'Jared Leto'),
        Cast(movie_five.id, 'Josh Lucas'),
        Cast(movie_five.id, 'Samantha Mathis'),
        Cast(movie_five.id, 'Chloe Sevigny'),
        Director(movie_five.id, 'Mary Harron'),
        Genre(movie_six.id, 'Action & Adventure'),
        Genre(movie_six.id, 'Romance'),
        Cast(movie_six.id, 'Rosa Salazar'),
        Cast(movie_six.id, 'Christoph Waltz'),
        Cast(movie_six.id, 'Jennifer Connelly'),
        Cast(movie_six.id, 'Mahershala Ali'),
        Cast(movie_six.id, 'Ed Skrein'),
        Cast(movie_six.id, 'Jackie Earle Haley'),
        Director(movie_six.id, 'Robert Rodriguez'),
        Showing(
            movie_six.id, theater_one.id,
            'https://www.amctheatres.com/showtimes/alita-battle-angel-43118/2019-02-13/amc-pacific-place-11/all',
            '2019-02-13', '7:00pm'),
        Showing(
            movie_six.id, theater_one.id,
            'https://www.amctheatres.com/showtimes/alita-battle-angel-43118/2019-02-13/amc-pacific-place-11/all',
            '2019-02-13', '9:55pm'),
        Showing(
            movie_six.id, theater_two.id,
            'https://www.amctheatres.com/showtimes/alita-battle-angel-43118/2019-02-13/amc-oak-tree-6/all',
            '2019-02-13', '7:00pm'),
        Showing(
            movie_six.id, theater_two.id,
            'https://www.amctheatres.com/showtimes/alita-battle-angel-43118/2019-02-13/amc-oak-tree-6/all',
            '2019-02-13', '9:15pm'),
        Showing(
            movie_six.id, theater_three.id,
            'https://www.amctheatres.com/showtimes/alita-battle-angel-43118/2019-02-13/amc-seattle-10/all',
            '2019-02-13', '7:00pm'),
        Showing(
            movie_six.id, theater_three.id,
            'https://www.amctheatres.com/showtimes/alita-battle-angel-43118/2019-02-14/amc-seattle-10/all',
            '2019-02-14', '4:30pm'),
        Showing(
            movie_six.id, theater_three.id,
            'https://www.amctheatres.com/showtimes/alita-battle-angel-43118/2019-02-14/amc-seattle-10/all',
            '2019-02-14', '7:20pm'),
        Showing(
            movie_six.id, theater_three.id,
            'https://www.amctheatres.com/showtimes/alita-battle-angel-43118/2019-02-14/amc-seattle-10/all',
            '2019-02-14', '10:10pm')
    ])
    db_session.commit()
Ejemplo n.º 26
0
# pylint: disable=invalid-name
import sys
import uuid
from server.database import db_session
from server.models import Organization

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage: python -m scripts.create-org <org_name>")
        sys.exit(1)

    org = Organization(id=str(uuid.uuid4()), name=sys.argv[1])
    db_session.add(org)
    db_session.commit()
    print(org.id)
Ejemplo n.º 27
0
def register_stock_exchange(name: str, ) -> StockExchange:
    """Store the stock exchange name in the database"""
    stock_exchange = StockExchange(name=name)
    db_session.add(stock_exchange)
    db_session.commit()
    return stock_exchange
Ejemplo n.º 28
0
def delete_expense(info, id=None):
    query = Expense.get_query(info)
    if id:
        record = query.filter(ExpenseModel.id == id).one()
        db_session.delete(record)
        db_session.commit()