Guest User

Untitled

a guest
Aug 2nd, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. """seed rss feeds
  2.  
  3. Revision ID: 4296ad40d9d5
  4. Revises: 4465bb008a8a
  5. Create Date: 2014-07-30 20:23:31.363516
  6.  
  7. """
  8.  
  9. # revision identifiers, used by Alembic.
  10. revision = '4296ad40d9d5'
  11. down_revision = '4465bb008a8a'
  12.  
  13. from alembic import op
  14. import sqlalchemy as sa
  15. import time
  16. import datetime
  17. from dateutil.parser import parse
  18. import pytz
  19.  
  20. def upgrade():
  21.     """Preseed data into the system."""
  22.     current_context = op.get_context()
  23.     meta = current_context.opts['target_metadata']
  24.     rssfeed = sa.Table('rssfeeds', meta, autoload=True)
  25.  
  26.     # t0 = time.gmtime(0)
  27.     # # convert the struct_time to a datetime
  28.     # latest_post = datetime.datetime(*t0[:6])
  29.  
  30.             # 'Fri, 01 Aug 2014 00:41:29 +0000' %a, %d %b %Y %H:%M:%S %z
  31.  
  32.     latest_post = datetime.datetime(1970, 1, 1, 1, 1, 1, 1, pytz.UTC) # a long time ago
  33.  
  34.     # Add the initial admin rssfeed account.
  35.     op.bulk_insert(rssfeed, [{
  36.         'url': u'http://www.utah.gov/whatsnew/rss.xml',
  37.         'name': u'utah',
  38.         'latestpost': latest_post,
  39.         }
  40.     ])
  41.  
  42.  
  43. def downgrade():
  44.     pass
Advertisement
Add Comment
Please, Sign In to add comment