Movie_dashboard / app.py
Penguni's picture
Create app.py
90a6c5f verified
raw
history blame
2.53 kB
import sqlite3
import streamlit as st
# Function to query the database and get the number of movies
def get_movie_count():
# Connect to the SQLite database
conn = sqlite3.connect('imdb.db')
cursor = conn.cursor()
# Query to count the number of movies
cursor.execute('SELECT COUNT(*) FROM title_basics WHERE titleType = "movie"')
movie_count = cursor.fetchone()[0]
# Close the connection
conn.close()
return movie_count
# Function to query the database and get the number of unique languages
def get_language_count():
# Connect to the SQLite database
conn = sqlite3.connect('imdb.db')
cursor = conn.cursor()
# Query to count the number of unique languages
cursor.execute('SELECT COUNT(DISTINCT language) FROM title_basics')
language_count = cursor.fetchone()[0]
# Close the connection
conn.close()
return language_count
# Function to query the database and get the number of unique countries
def get_country_count():
# Connect to the SQLite database
conn = sqlite3.connect('imdb.db')
cursor = conn.cursor()
# Query to count the number of unique countries
cursor.execute('SELECT COUNT(DISTINCT country) FROM title_basics')
country_count = cursor.fetchone()[0]
# Close the connection
conn.close()
return country_count
# Main Streamlit app
def main():
# Title
st.title('IMDb Dataset Statistics')
# Create a 3-column layout using Streamlit
col1, col2, col3 = st.columns(3)
# Column 1: Number of Movies
with col1:
st.markdown('<span class="material-icons-outlined" style="font-size: 48px;">movie</span>', unsafe_allow_html=True)
st.markdown(f'<div style="text-align: center; font-size: 24px;">Movies: <strong>{get_movie_count()}</strong></div>', unsafe_allow_html=True)
# Column 2: Number of Languages
with col2:
st.markdown('<span class="material-icons-outlined" style="font-size: 48px;">language</span>', unsafe_allow_html=True)
st.markdown(f'<div style="text-align: center; font-size: 24px;">Languages: <strong>{get_language_count()}</strong></div>', unsafe_allow_html=True)
# Column 3: Number of Countries
with col3:
st.markdown('<span class="material-icons-outlined" style="font-size: 48px;">public</span>', unsafe_allow_html=True)
st.markdown(f'<div style="text-align: center; font-size: 24px;">Countries: <strong>{get_country_count()}</strong></div>', unsafe_allow_html=True)
if __name__ == '__main__':
main()