Some of these methods can be used to interact with a SQLite3 database. Others are useful if you’d like to interact with the article data.
Commits RSS news feeds to a SQLite3 database
Creates tables for RSS news feeds
Creates db tables where each RSS link feeds into a separate table because it’s easier to aggregate then deaggregate.
Fix the create table bug
In GatherNews 0.1.0, a bug was introduced that does not allow you to add new RSS feeds to the ‘feeds_list.txt’ after your initial call of the create_tables() method.
This method was created because we have no way of knowing which RSS feed links match which RSS table names without making a call to each RSS feed and recreating each table name.
If you have previously used GatherNews 0.1.0 you should call this method once before calling any other methods on your previously created ‘FeedMe.db’. Once this method is called then the issue should be resolved.
RSS links used to pull feeds
All table names are extracted for use in SQL queries.
Loads the sqlite3 database
Make the table names for the sqlite3 database.
Queries are matched with dict keys which then provides the values associated with each query by sharing the table names as a reference point. This allows rows to be populated for each table leading to the population of the db.
Reads in file so that only rss links are included
Unfortunately, .readlines() or .read() alone was sucking in extra ‘
expressions to only list items that are consistent with an RSS feed link.
Limitation of this duplicate removal approach is that only one duplicate entry will be removed (containing the lowest valued primary_key). If the number of duplicate entries per item > 2 then that will introduce a bug.
Dictionary of table names mapped to a list of tuples for articles
This data structure is the ‘last stop’ before the article information is loaded into the SQL database. As such, it can also be called by itself; if loading a database is not what we want to do.