aboutsummaryrefslogtreecommitdiff
path: root/source/sqlite2mongo.py
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2012-09-10 15:32:22 +0200
committercedricbonhomme <devnull@localhost>2012-09-10 15:32:22 +0200
commitd7ebbf9fc6ae16eb97174d64c397b7e17c93e665 (patch)
tree93ab44eea55552afb0968b3aa818c926652484cb /source/sqlite2mongo.py
parentMinor changes to the CSS. (diff)
downloadnewspipe-d7ebbf9fc6ae16eb97174d64c397b7e17c93e665.tar.gz
newspipe-d7ebbf9fc6ae16eb97174d64c397b7e17c93e665.tar.bz2
newspipe-d7ebbf9fc6ae16eb97174d64c397b7e17c93e665.zip
Removed sqlite2mongo.py which was used during the migration from SQLite to MongoDB.
Diffstat (limited to 'source/sqlite2mongo.py')
-rw-r--r--source/sqlite2mongo.py77
1 files changed, 0 insertions, 77 deletions
diff --git a/source/sqlite2mongo.py b/source/sqlite2mongo.py
deleted file mode 100644
index ecb0ec7f..00000000
--- a/source/sqlite2mongo.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import hashlib
-import sqlite3
-
-import mongodb
-import utils
-
-from datetime import datetime
-
-SQLITE_BASE = "./var/feed.db"
-
-def sqlite2mongo():
- """
- Load feeds and articles in a dictionary.
- """
- mongo = mongodb.Articles()
- list_of_feeds = []
- list_of_articles = []
-
- try:
- conn = sqlite3.connect(SQLITE_BASE, isolation_level = None)
- c = conn.cursor()
- list_of_feeds = c.execute("SELECT * FROM feeds").fetchall()
- except:
- pass
-
- if list_of_feeds != []:
- # Walk through the list of feeds
- for feed in list_of_feeds:
- try:
- list_of_articles = c.execute(\
- "SELECT * FROM articles WHERE feed_link='" + \
- feed[2] + "'").fetchall()
- except:
- continue
- sha1_hash = hashlib.sha1()
- sha1_hash.update(feed[2].encode('utf-8'))
- feed_id = sha1_hash.hexdigest()
-
- new_collection = {"feed_id" : feed_id.encode('utf-8'), \
- "type": 0, \
- "feed_image" : feed[3].encode('utf-8'), \
- "feed_title" : feed[0].encode('utf-8'), \
- "feed_link" : feed[2].encode('utf-8'), \
- "site_link" : feed[1].encode('utf-8'), \
- "mail" : feed[4]=="1"}
-
- mongo.add_collection(new_collection)
-
- if list_of_articles != []:
- # Walk through the list of articles for the current feed.
- articles = []
- for article in list_of_articles:
- sha1_hash = hashlib.sha1()
- sha1_hash.update(article[2].encode('utf-8'))
- article_id = sha1_hash.hexdigest()
-
- article = {"article_id": article_id.encode('utf-8'), \
- "type":1, \
- "article_date": utils.string_to_datetime(article[0]), \
- "article_link": article[2].encode('utf-8'), \
- "article_title": article[1].encode('utf-8'), \
- "article_content": article[3].encode('utf-8'), \
- "article_readed": article[4]=="1", \
- "article_like": article[6]=="1" \
- }
-
- articles.append(article)
-
- mongo.add_articles(articles, feed_id)
-
- c.close()
-
-if __name__ == "__main__":
- sqlite2mongo() \ No newline at end of file
bgstack15