-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.py
31 lines (23 loc) · 820 Bytes
/
database.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
import db_util
def add_to_db(email_id, tvSeriesString):
cur = db_util.db.cursor()
try:
cur.execute('CREATE DATABASE IF NOT EXISTS mydatabase;')
#print('----DB created----')
except:
print('----Error in creating database!!----')
db_util.db.commit()
try:
q4 = 'USE mydatabase;'
cur.execute(q4)
#print('----Using mydatabase----')
except:
print('----Error in creating database!!----')
q2 = 'create table IF NOT EXISTS series (email varchar(100) default NULL, tv varchar(255) default NULL);'
cur.execute(q2)
db_util.db.commit()
q3 = "INSERT INTO series (email, tv) VALUES (%s, %s)"
cur.execute(q3,(email_id, tvSeriesString))
db_util.db.commit()
#print '----Entries recorded in DB----'
db_util.db.close()