Exemplo n.º 1
0
def main():

    args = get_args()

    if args.database == 'sqlite':
        # Option to use SQLite instead of PostgreSQL
        engine = create_engine('sqlite:///sqlite3.db')
        # sqlite session
        engine, session = create_sqlite_session(engine=engine)

        Base.metadata.create_all(engine)

        # Autoload some data without user/CLI interface
        insert_category_data(session=session)
        insert_director_data(session=session)
        insert_actor_data(session=session)
        insert_account_data(session=session)
        insert_movie_data(session=session)
        insert_theater_data(session=session)

        print_header()

        try:
            while True:
                if find_user_intent() == 'find':
                    cinephile_sqlite.run()
                else:
                    theater_owner_sqlite.run()
        except KeyboardInterrupt:
            return

        session.close()

    else:
        # postgresql session
        engine, session = create_session()

        Base.metadata.create_all(engine)

        # Autoload some data without user/CLI interface
        insert_category_data(session=session)
        insert_director_data(session=session)
        insert_actor_data(session=session)
        insert_account_data(session=session)
        insert_movie_data(session=session)
        insert_theater_data(session=session)

        print_header()

        try:
            while True:
                if find_user_intent() == 'find':
                    cinephile.run()
                else:
                    theater_owner.run()
        except KeyboardInterrupt:
            return

        session.close()
Exemplo n.º 2
0
from pydango.tables import (
    Account,
    Category,
    Movie,
    Payment,
    Ticket,
    Theater,
    theater_schedule,
)

from sqlalchemy.sql import (
    update,
    and_,
)

engine, session = create_session()


def run():
    print('****************** Hello Cinephile ******************')
    print()

    show_commands()

    while True:
        action = primary_func.get_action()

        with switch(action) as s:
            s.case('c', create_account)
            s.case('l', log_into_account)
            s.case('o', logout)