def post(self): args = self.reqparse.parse_args() note = Note(args['note'], datetime.now()) db_session.add(note) db_session.commit() return {'note': marshal(note, task_fields) }, 201
def process_item(self, post, spider): if P.query.filter_by(post_id=post['post_id']).count() == 1: raise DropItem("Item already exists") else: db_post = P( post_id=post['post_id'], title=post['title'], body=post['body'], # email=post['email'], timestamp=post['timestamp'], url=post['url'], ) db_session.add(db_post) db_session.commit() db_session.close() return post
import sys sys.path.append('/Users/nick/Sites/apix/webjobs/') from modules.database import engine, db_session, Base, City, Post, Update with open('craigs_city_list.txt') as f: cities = f.readlines() for city in cities: db_session.add(City(name=city.strip())) db_session.commit()