case studyclassifying reddit posts listing setting up sqllite database and reddit api client import praw import sqlite import praw and sqlite libraries conn sqlite connect('reddit db' conn cursor(set up connection to sqlite database execute('''drop table if exists topics''' execute('''drop table if exists comments''' execute('''create table topics (topictitle texttopictext texttopicid texttopiccategory text)''' execute('''create table comments (commenttext textcommentid text topictitle texttopictext texttopicid text topiccategory text)'''user_agent "introducing data science bookr praw reddit(user_agent=user_agentcreate praw user agent so we can use reddit api subreddits ['datascience','gameofthrones'limit execute sql statements to create topics and comments table maximum number of posts we'll fetch from reddit per category maximum reddit allows at any single time is also , our list of subreddits we'll draw into our sqlite database let' first import the necessary libraries now that we have access to the sqlite and praw capabilitieswe need to prepare our little local database for the data it' about to receive by defining connection to sqlite file we automatically create it if it doesn' already exist we then define data cursor that' capable of executing any sql statementso we use it to predefine the structure of our database the database will contain two tablesthe topics table contains reddit topicswhich is similar to someone starting new post on forumand the second table contains the comments and is linked to the topic table via the "topicidcolumn the two tables have one (topic tableto many (comment tablerelationship for the case studywe'll limit ourselves to using the topics tablebut the data collection will incorporate both because this allows you to experiment with this extra data if you feel like it to hone your text-mining skills you could perform sentiment analysis on the topic comments and find out what topics receive negative or positive comments you could then correlate this to the model features we'll produce by the end of this we need to create praw client to get access to the data every subreddit can be identified by its nameand we're interested in "datascienceand "gameofthrones the limit represents the maximum number of topics (postsnot commentswe'll draw in from reddit thousand is also the maximum number the api allows us to fetch at any given requestthough we could request more later on when people have