-
Notifications
You must be signed in to change notification settings - Fork 0
/
Movies_db.py
115 lines (82 loc) · 2.2 KB
/
Movies_db.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import sqlite3
#Query THE DB and return all records
def show_all():
conn = sqlite3.connect('Movieslist.db')
#Create a cursor
c= conn.cursor()
#QUERY
c.execute("SELECT rowid,* FROM movies")
items = (c.fetchall())
for item in items:
print(item)
# Commit the command
conn.commit()
#Close our connection
conn.close()
#Add new record
def addmovie(movie,actor,actress,director,year):
conn = sqlite3.connect('Movieslist.db')
c = conn.cursor()
c.execute("INSERT INTO movies VALUES (?,?,?,?,?)",(movie,actor,actress,director,year))
# Commit the command
conn.commit()
#Close our connection
conn.close()
#Delete record
c.execute("DELETE FROM movies WHERE rowid =7")
#Lookup
def movie_lookup(movie):
conn = sqlite3.connect('Movieslist.db')
c = conn.cursor()
c.execute("SELECT * FROM movies WHERE Movie_name =(?)",(movie,))
items = (c.fetchall())
for item in items:
print(item)
# Commit the command
conn.commit()
#Close our connection
conn.close()
def actor_lookup(actor):
conn = sqlite3.connect('Movieslist.db')
c = conn.cursor()
c.execute("SELECT * FROM movies WHERE Actor =(?)",(actor,))
items = (c.fetchall())
for item in items:
print(item)
# Commit the command
conn.commit()
#Close our connection
conn.close()
def actress_lookup(actress):
conn = sqlite3.connect('Movieslist.db')
c = conn.cursor()
c.execute("SELECT * FROM movies WHERE Actress =(?)",(actress,))
items = (c.fetchall())
for item in items:
print(item)
# Commit the command
conn.commit()
#Close our connection
conn.close()
def director_lookup(director):
conn = sqlite3.connect('Movieslist.db')
c = conn.cursor()
c.execute("SELECT * FROM movies WHERE Director =(?)",(director,))
items = (c.fetchall())
for item in items:
print(item)
# Commit the command
conn.commit()
#Close our connection
conn.close()
def year_lookup(year):
conn = sqlite3.connect('Movieslist.db')
c = conn.cursor()
c.execute("SELECT * FROM movies WHERE Year = (?)",(year,))
items = (c.fetchall())
for item in items:
print(item)
# Commit the command
conn.commit()
#Close our connection
conn.close()