aboutsummaryrefslogtreecommitdiff
path: root/feedgetter.py
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2010-01-30 08:51:09 +0100
committercedricbonhomme <devnull@localhost>2010-01-30 08:51:09 +0100
commit6eea7fef16b5bc7120cf919eeffcfe1145b58793 (patch)
tree82a7502acf9fc1fc8f6423c035e2ca1452f69db0 /feedgetter.py
parentAdded : UTF-8 encoding of web pages and a link for the management of feed. (diff)
downloadnewspipe-6eea7fef16b5bc7120cf919eeffcfe1145b58793.tar.gz
newspipe-6eea7fef16b5bc7120cf919eeffcfe1145b58793.tar.bz2
newspipe-6eea7fef16b5bc7120cf919eeffcfe1145b58793.zip
Added : primary key in the SQLite base and check the existence of table.
Diffstat (limited to 'feedgetter.py')
-rw-r--r--feedgetter.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/feedgetter.py b/feedgetter.py
index 0884f7e1..5a560763 100644
--- a/feedgetter.py
+++ b/feedgetter.py
@@ -38,8 +38,9 @@ def retrieve_feed():
"""
conn = sqlite3.connect("./var/feed.db", isolation_level = None)
c = conn.cursor()
- c.execute('''create table rss_feed
- (date text, feed_title text, feed_site_link text, article_title text , article_link text)''')
+ c.execute('''create table if not exists rss_feed
+ (date text, feed_title text, feed_site_link text, \
+ article_title text, article_link text PRIMARY KEY)''')
for a_feed in feeds_file.readlines():
# test if the URL is well formed
@@ -63,12 +64,15 @@ def retrieve_feed():
# when all jobs are done, insert articles in the base
for a_feed in feeds_list:
for article in a_feed['entries']:
- c.execute('insert into rss_feed values (?,?,?,?,?)', (\
- "-".join([str(i) for i in list(article.updated_parsed)]), \
- a_feed.feed.title.encode('utf-8'), \
- a_feed.feed.link.encode('utf-8'), \
- article.title.encode('utf-8'), \
- article.link.encode('utf-8')))
+ try:
+ c.execute('insert into rss_feed values (?,?,?,?,?)', (\
+ "-".join([str(i) for i in list(article.updated_parsed)]), \
+ a_feed.feed.title.encode('utf-8'), \
+ a_feed.feed.link.encode('utf-8'), \
+ article.title.encode('utf-8'), \
+ article.link.encode('utf-8')))
+ except sqlite3.IntegrityError:
+ pass
conn.commit()
c.close()
bgstack15