else/HerokuBot/herokubot.py
Voussoir f13db2ae88 else
totaldl 1
2015-05-14 22:40:19 -07:00

28 lines
No EOL
706 B
Python

import praw
import time
import sqlite3
print('Logging in.')
r = praw.Reddit('Testing praw api usage over Heroku')
r.login('qQGusVuAHezHxhYTiYGm', 'qQGusVuAHezHxhYTiYGm')
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()
print('Getting subreddit info.')
sub = r.get_subreddit('Goldtesting')
print('/r/Goldtesting')
print('\tCreated at: %d' % sub.created_utc)
print('\tSubscribers: %d' % sub.subscribers)
print('Saving subreddit info.')
cur.execute('INSERT INTO subreddits VALUES(?, ?)', ['Goldtesting', sub.subscribers])
sql.commit()
print('All done!')
while True:
time.sleep(60)