-
Notifications
You must be signed in to change notification settings - Fork 52
/
MiniProject_Backend.py
47 lines (40 loc) · 1.9 KB
/
MiniProject_Backend.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
#backend
import sqlite3
def MovieData():
con=sqlite3.connect("movie1.db")
cur=con.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS book (id INTEGER PRIMARY KEY, Movie_ID text,Movie_Name text,Release_Date text,Director text,Cast text,Budget text,Duration text,Rating text")
con.commit()
con.close()
def AddMovieRec(Movie_ID,Movie_Name,Release_Date,Director,Cast,Budget,Duration,Rating):
con=sqlite3.connect("movie1.db")
cur=con.cursor()
cur.execute("INSERT INTO book VALUES (NULL, ?,?,?,?,?,?,?,?)", (Movie_ID,Movie_Name,Release_Date,Director,Cast,Budget,Duration,Rating))
con.commit()
con.close()
def ViewMovieData():
con=sqlite3.connect("movie1.db")
cur=con.cursor()
cur.execute("SELECT * FROM book")
rows=cur.fetchall()
con.close()
return rows
def DeleteMovieRec(id):
con=sqlite3.connect("movie1.db")
cur=con.cursor()
cur.execute("DELETE FROM book WHERE id=?", (id,))
con.commit()
con.close()
def SearchMovieData(Movie_ID="",Movie_Name="",Release_Date="",Director="",Cast="",Budget="",Duration="",Rating=""):
con=sqlite3.connect("movie1.db")
cur=con.cursor()
cur.execute("SELECT * FROM book WHERE Movie_ID=? OR Movie_Name=? OR Release_Date=? OR Director=? OR Cast=? OR Budget=? OR Duration=? OR Rating=?",(Movie_ID,Movie_Name,Release_Date,Director,Cast,Budget,Duration,Rating))
rows=cur.fetchall()
con.close()
return rows
def UpdateMovieData(id,Movie_ID="",Movie_Name="",Release_Date="",Director="",Cast="",Budget="",Duration="",Rating=""):
con=sqlite3.connect("movie1.db")
cur=con.cursor()
cur.execute("UPDATE book SET Movie_ID=?,Movie_Name=?,Release_Date=?,Director=?,Cast=?,Budget=?,Duration=?,Rating=?, WHERE id=?",(Movie_ID,Movie_Name,Release_Date,Director,Cast,Budget,Duration,Rating))
con.commit()
con.close()