-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_data.py
41 lines (41 loc) · 1.4 KB
/
load_data.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
import mysql.connector
class load_data():
def __init__(self):
self.cnx = mysql.connector.connect(user='Adi', password='Adicoco0410',database='song_data')
self.cursor=self.cnx.cursor()
def search_song(self,song):
query=("SELECT * FROM songlist WHERE song like ")
query=query+'\'%'+song+'%\''
print(query)
self.cursor.execute(query)
song_list=[]
link_list=[]
for (song,singer,CD,moods,link) in self.cursor:
song_list.append(song)
link_list.append(link)
return song_list,link_list
def search_singer(self,singer):
query=("SELECT * FROM songlist WHERE singer like ")
query=query+'\'%'+singer+'%\''
print(query)
self.cursor.execute(query)
song_list=[]
link_list=[]
for (song,singer,CD,moods,link) in self.cursor:
song_list.append(song)
link_list.append(link)
return song_list,link_list
def search_mood(self,mood):
query=("SELECT * FROM songlist WHERE moods like ")
query=query+'\'%'+mood+'%\''
print(query)
self.cursor.execute(query)
song_list=[]
link_list=[]
for (song,singer,CD,moods,link) in self.cursor:
song_list.append(song)
link_list.append(link)
return song_list,link_list
if __name__ == '__main__':
ld=load_data()
# ld.output_link