In order to set up automatic RSS parsing, we need to create a cronjob that runs cron_jobs.py
in terminal:
crontab -e
for example, if my cron_job.py scripts location is: /home/ocean/brian-fantasy/fantasyfootballtracker-fixed/cron_script.py, then copy this in to crontab
*/10 * * * * /home/ocean/brian-fantasy/fantasyfootballtracker-fixed/cron_script.py
this will run the cron_script every 10 minutes.
After this, you can comment out these lines in app/views.py. in get_rss() function. ~line 136
#rss_parser = RSS_Parser()
#yahoo_db_helper = Db_Helper()
#rss_dict = rss_parser.return_data()
#yahoo_db_helper.load_rss_dict(rss_dict)
first wiki link. may not work since linking to my repo
install these packages with apt-get, brew, yum, whatever:
postgresql pgadmin3 postgresql-client postgresql-contrib libpq-dev postgresql-server-dev-all sudo apt-get install python-dev
after hg cloning, run this command to install the virtual enviornment & the requirements into .env
$ virtualenv --no-site-packages --distribute .env && source .env/bin/activate && pip install -r requirements.txt
to activate the env:
$ source .env/bin/activate
to deactivate env:
$ deactivate
i had a lot of trouble installing + configuring. it's OS dependant, so figure out how to get postgresql running on your machine. expect to spend at least an hour configuring. lol. The general idea is to:
-
install postgresql
-
configure postgresql -- follow this tutorial setting up postgres account: https://help.ubuntu.com/community/PostgreSQL. Postgres account is used for nfldb tutorial might as well do it now. -- please edit file /etc/postgresql/9.1/main/pg_hba.conf wherever you see
local all postgres peer
----change to-----local all postgres md5
-
import nfldb.sql data into postgresql
-
install nflgame
Here is the tutorial for installing configuring nfldb:
https://github.com/BurntSushi/nfldb/wiki/Installation
the guides instructions are for archlinux so if you are using debian like me, the commands are a bit different...
After configuring postgresql permissions properly, you should be able to create nfldb user with password nfldb, and nfldb db by running:
createuser -U postgres -E -P nfldb
createdb -U postgres -O nfldb nfldb
psql -U postgres -c 'CREATE EXTENSION fuzzystrmatch;'
psql -U nfldb nfldb
If this doesnt work:
psql -U nfldb -d nfldb
If any of the permission/config file settings are incorrect, you won't be able to run those commands. If you installed everything properly and followed the guide, you should be able to run:
nfldb-update
*****If you encounter an error about write access to json files, please run the following script
sudo chmod -R ugo+rw /folderOrFile_name
Once done, open pgadmin3 connect to localhost, click on nfldb database and create a new query. Make sure that the new query window opened has a title of "Query - nfldb". Open location db_schema/scripts and execute all scripts in order that you havent ran in your db yet.
##sqlAlchemy Models
- sqlAlchemy Models do not support backref as of right now so don't try to use it. I am having issues adding a relationship
to manual orm. However, the models do know there is a relationship existing between them and you can still join on the fly. For example:
league=db_session.query(F_League).join(User).filter_by(user_id=1).first()