2015-05-01 00:51:49 +00:00
|
|
|
import praw
|
|
|
|
import time
|
2015-05-15 05:40:19 +00:00
|
|
|
import sqlite3
|
2015-05-01 00:51:49 +00:00
|
|
|
|
|
|
|
print('Logging in.')
|
|
|
|
r = praw.Reddit('Testing praw api usage over Heroku')
|
|
|
|
r.login('qQGusVuAHezHxhYTiYGm', 'qQGusVuAHezHxhYTiYGm')
|
|
|
|
|
2015-05-15 05:40:19 +00:00
|
|
|
print('Loading database')
|
|
|
|
sql = sqlite3.connect('sql.db')
|
|
|
|
cur = sql.cursor()
|
|
|
|
|
|
|
|
cur.execute('CREATE TABLE IF NOT EXISTS subreddits(name TEXT, subscribers INT)')
|
|
|
|
sql.commit()
|
|
|
|
|
2015-05-01 00:51:49 +00:00
|
|
|
print('Getting subreddit info.')
|
|
|
|
sub = r.get_subreddit('Goldtesting')
|
|
|
|
print('/r/Goldtesting')
|
|
|
|
print('\tCreated at: %d' % sub.created_utc)
|
|
|
|
print('\tSubscribers: %d' % sub.subscribers)
|
|
|
|
|
2015-05-15 05:40:19 +00:00
|
|
|
print('Saving subreddit info.')
|
|
|
|
cur.execute('INSERT INTO subreddits VALUES(?, ?)', ['Goldtesting', sub.subscribers])
|
|
|
|
sql.commit()
|
|
|
|
|
2015-05-01 00:51:49 +00:00
|
|
|
print('All done!')
|
|
|
|
while True:
|
|
|
|
time.sleep(60)
|