-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.py
100 lines (81 loc) · 2.88 KB
/
script.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
from Modules import dates
import sqlite3
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
#-----------------USER INPUT-----------------#
address= True
while address:
toaddr = input("Enter your Email address: ").replace(' ','')
if "@" and "." not in toaddr:
print(" ----------------------------------------")
print("| PLEASE ENTER CORRECT EMAIL ADDRESS !!! |")
print(" ----------------------------------------")
else:
address = False
mtvl=True
while mtvl:
movie_or_tv_show_list = list(map(str,input("Enter Movie or TV show separated by comma(,): ").split(',')))
if len(movie_or_tv_show_list) == 0:
print(" -------------------------------------")
print("| PLEASE ENTER A MOVIE OR TV SHOW !!! |")
print(" -------------------------------------")
else:
mtvl = False
#-------------STORE USER ENTERED DATA IN DATABASE-------------#
#-----------------DATABASE CONNECTION-----------------#
conn = sqlite3.connect('Database/database.db')
c = conn.cursor()
#--------------CREATE TABLE--------------#
def create_table():
c.execute('''CREATE TABLE DATAS
(email_id VARCHAR(255) NOT NULL,
movie_or_tvshow VARCHAR(255) NOT NULL);''')
create_table()
#--------------INSERT DATA INTO TABLE--------------#
def insert():
for movie_or_tv_show in movie_or_tv_show_list:
c.execute(
'''INSERT INTO DATAS(email_id,movie_or_tvshow) VALUES(?,?)''', (toaddr, movie_or_tv_show))
insert()
#--------------RETRIEVE DATA FROM TABLE--------------#
toaddr_from_db_list = []
movie_or_tv_show_list_from_db = []
def retrieve():
c.execute('''SELECT email_id FROM DATAS''')
for row in c.fetchone():
toaddr_from_db_list.append(row)
c.execute('''SELECT email_id,movie_or_tvshow FROM DATAS''')
for row in c.fetchall():
movie_or_tv_show_list_from_db.append(row[1])
retrieve()
#--------------DELETE THE CREATED TABLE AFTER RETRIEVING DATA--------------#
def drop_table():
c.execute('''DROP TABLE DATAS''')
drop_table()
#--------------COMMIT AND CLOSE THE DATABASE CONNECTION--------------#
conn.commit()
conn.close()
toaddr_from_db=toaddr_from_db_list[0]
fromaddr = "Your Email Address"
password = "Your Email Password"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr_from_db
msg['Subject'] = "Movie or TV show dates"
try:
for date in movie_or_tv_show_list_from_db:
date=date.replace(' ', '+')
body=dates.dates(date)
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, password)
text = msg.as_string()
server.sendmail(fromaddr, toaddr_from_db, text)
server.quit()
print(" ----------------")
print("| SUCCESS xD !!! |")
print(" ----------------")
except Exception as e:
pass