Penguni commited on
Commit
90a6c5f
·
verified ·
1 Parent(s): 62bf172

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +73 -0
app.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sqlite3
2
+ import streamlit as st
3
+
4
+ # Function to query the database and get the number of movies
5
+ def get_movie_count():
6
+ # Connect to the SQLite database
7
+ conn = sqlite3.connect('imdb.db')
8
+ cursor = conn.cursor()
9
+
10
+ # Query to count the number of movies
11
+ cursor.execute('SELECT COUNT(*) FROM title_basics WHERE titleType = "movie"')
12
+ movie_count = cursor.fetchone()[0]
13
+
14
+ # Close the connection
15
+ conn.close()
16
+
17
+ return movie_count
18
+
19
+ # Function to query the database and get the number of unique languages
20
+ def get_language_count():
21
+ # Connect to the SQLite database
22
+ conn = sqlite3.connect('imdb.db')
23
+ cursor = conn.cursor()
24
+
25
+ # Query to count the number of unique languages
26
+ cursor.execute('SELECT COUNT(DISTINCT language) FROM title_basics')
27
+ language_count = cursor.fetchone()[0]
28
+
29
+ # Close the connection
30
+ conn.close()
31
+
32
+ return language_count
33
+
34
+ # Function to query the database and get the number of unique countries
35
+ def get_country_count():
36
+ # Connect to the SQLite database
37
+ conn = sqlite3.connect('imdb.db')
38
+ cursor = conn.cursor()
39
+
40
+ # Query to count the number of unique countries
41
+ cursor.execute('SELECT COUNT(DISTINCT country) FROM title_basics')
42
+ country_count = cursor.fetchone()[0]
43
+
44
+ # Close the connection
45
+ conn.close()
46
+
47
+ return country_count
48
+
49
+ # Main Streamlit app
50
+ def main():
51
+ # Title
52
+ st.title('IMDb Dataset Statistics')
53
+
54
+ # Create a 3-column layout using Streamlit
55
+ col1, col2, col3 = st.columns(3)
56
+
57
+ # Column 1: Number of Movies
58
+ with col1:
59
+ st.markdown('<span class="material-icons-outlined" style="font-size: 48px;">movie</span>', unsafe_allow_html=True)
60
+ st.markdown(f'<div style="text-align: center; font-size: 24px;">Movies: <strong>{get_movie_count()}</strong></div>', unsafe_allow_html=True)
61
+
62
+ # Column 2: Number of Languages
63
+ with col2:
64
+ st.markdown('<span class="material-icons-outlined" style="font-size: 48px;">language</span>', unsafe_allow_html=True)
65
+ st.markdown(f'<div style="text-align: center; font-size: 24px;">Languages: <strong>{get_language_count()}</strong></div>', unsafe_allow_html=True)
66
+
67
+ # Column 3: Number of Countries
68
+ with col3:
69
+ st.markdown('<span class="material-icons-outlined" style="font-size: 48px;">public</span>', unsafe_allow_html=True)
70
+ st.markdown(f'<div style="text-align: center; font-size: 24px;">Countries: <strong>{get_country_count()}</strong></div>', unsafe_allow_html=True)
71
+
72
+ if __name__ == '__main__':
73
+ main()