forked from j4rj4r/BotTwitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage_rss.py
50 lines (41 loc) · 1.25 KB
/
manage_rss.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
# Standard libraries
import sqlite3
class ManageRss:
def __init__(self):
"""
GestionRss constructor
"""
def add_link(self, link):
"""
Add a link to the database
:param link String: link of an rss article
"""
connection = sqlite3.connect('data.db')
c = connection.cursor()
c.execute('''INSERT INTO rss_links (link) VALUES (:link);''', (link,))
c.close()
connection.commit()
def link_exist(self, link):
"""
Returns true if the link exists in the database.
:param link String: Link of an rss article
"""
connection = sqlite3.connect('data.db')
c = connection.cursor()
c.execute('''SELECT * FROM rss_links WHERE link = ?;''', (link,))
data = c.fetchall()
# If this link exist or not
if len(data) == 0:
return False
else:
return True
def create_table_rss():
"""
Create new tables to save the rss links.
"""
connection = sqlite3.connect('data.db')
c = connection.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS rss_links
(id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, link text);''')
c.close()
connection.commit()