Welcome to pydango-pip’s documentation!

Pydango-pip is a pip-intallable database schema that you can interact with through a CLI. The schema is meant to mimic a movie theater reservation system such as Fandango.

The inspiration came from a YouTube video by Mike Kennedy where he builds an Air Bnb-like CLI for MongoDB with MongoEngine. I’ve taken a lot of his code and refactored it for SQLAlchemy and relational databases. You can find the video here: https://youtu.be/E-1xI85Zog8.

You can also find the non-pip-installable version of Pydango called simply “Pydango” here: https://github.com/Captmoonshot/pydango .

This regular version of Pydango is good to clone and interact with through both the CLI and a database backend to really grokk what goes on behind the scenes. Once you clone it, and set up a configuration file, you can use it for both an SQLite and/or PostgreSQL database backend.

However, pydango-pip will only work with SQLite database backends.

pydango.__main__.get_args()

Function to parse arguments from the command-line using the argparse module

Returns

arguments

pydango.__main__.main()

Pydango-pip’s main executable function. Gets the database argument from the command-line. Using SQLAlchemy’s ORM pattern, creates an engine and session. The session is then used to create the database schema: tables and relations.

We then automatically load initial data into those tables using insert_<table_name>_data(session=session) functions.

We then divide our users into two distinct groups with the find_user_intent function:

  1. cinephile (people who want to watch movies)

  2. theater_owner (people who own movies theaters and supply the movies to watch)

And execute the CLI flow for the respective user types.

pydango-pip’s ORM Relationships

The following classes represent the Python classes that gets mapped to their SQL equivalents using SQLAlchemy ORM’s declarative syntax which allows for things like Many-to-One and Many-to-Many relationships.

class pydango.tables.Account(**kwargs)

Class that maps to the account table in the database and hold data about user accounts

class pydango.tables.Actor(**kwargs)

Class that maps to actor table in the database and hold data about actors

class pydango.tables.Category(**kwargs)

Class that maps to category table in database and holds data about movie categories

class pydango.tables.Director(**kwargs)

Class that maps to director table in the database and holds data about movie directors

class pydango.tables.Movie(**kwargs)

Class that maps to movie table in the database and holds data about movies

class pydango.tables.Payment(**kwargs)

Class that maps to payment table in the database and holds data about ticket payments

class pydango.tables.Theater(**kwargs)

Class that maps to theater table in the database and holds data about movie theaters

class pydango.tables.TheaterMovie(**kwargs)

Class that links movies and theaters in a Many-To-Many relation aka Association object in SQLAlchemy parlance.

Association objects allow extra data on top of the ForeignKeys as attributes for the relationship.

class pydango.tables.Ticket(**kwargs)

Class that maps to ticket table in the database and holds data about movies, theaters, schedules, accounts, and price of tickets

CLI for Cinephile

The following functions represent the CLI flow for cinephile-type users. These are users who want to watch movies and will be searching for movies and purchasing tickets from theater_owner-type users.

pydango.cinephile_sqlite.browse_by_category()

Function to filter movies by their categories

pydango.cinephile_sqlite.browse_by_location()

Function to filter movies and theaters by zip_code or city attribute of Theater class

pydango.cinephile_sqlite.create_account()

Function to register a cinephile user

All inputs are given by the user through a CLI

pydango.cinephile_sqlite.list_movies()

Function to list all active movies in the movie table

pydango.cinephile_sqlite.log_into_account()

Function to log into account

Returns

state.active_account

pydango.cinephile_sqlite.logout()

Function to log out of the account

pydango.cinephile_sqlite.purchase_ticket()

Function to allow the user to purchase a ticket based on movies, theaters, and their schedules

pydango.cinephile_sqlite.run()

The main executable function for the cinephile type of user

pydango.cinephile_sqlite.show_commands()

Function to display a choice menu to the cinephile type of user

pydango.cinephile_sqlite.view_ticket()

Function to view the account’s associated ticket they purchased for the day of purchase. Other previous tickets before datetime.datetime.today() are considered expired and not shown

CLI for Theater-owner

The following functions represent the CLI flow for theater_owner-type users. These are users who want to list movies that are currently playing and will be selling tickets to cinephile- type users.

pydango.theater_owner_sqlite.add_movie_to_existing_theater()

Function to add a movie object to an exisint movie theater using a Many-to-Many relationship

pydango.theater_owner_sqlite.add_schedule_to_existing_theater()

Function to add a unique schedule to an existing movie theater

pydango.theater_owner_sqlite.create_account()

Function to allow users to create a theater_owner-type account which is different from the cinephile-type account

pydango.theater_owner_sqlite.create_actor()

Function to create an actor

pydango.theater_owner_sqlite.create_movie()

Function to create a movie object along with the associated theater object

pydango.theater_owner_sqlite.create_theater()

Function to create a theater object

pydango.theater_owner_sqlite.run()

The main executable function for theater-owner type users

pydango.theater_owner_sqlite.show_commands()

Function to display choice menu to theater-owners. This list of commands is different from the show_commands for cinephile-type users

Indices and tables