File size: 2,529 Bytes
90a6c5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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()