def add_collection_item(collection, collection_item): """ Used initially just to import data from csv into sqlite """ session = common.DBSession() collection_item.collections_id = collection.id session.add(collection_item)
def add_collection(collection): """ Used initially just to import data from csv into sqlite """ session = common.DBSession() c = session.query(Collection).filter_by(id=collection.id).first() if c is None: session.add(collection) session.flush() c = collection return c
def _get_random(pos): session = common.DBSession() query = session.query(Bert) query = query.filter_by(pos=pos) results = query.all() offset = random.randint(0, len(results) - 1) result = results[offset] if result is None: result = Bert() result.pos = pos if result.text == '': result.text = 'Erm, well, what were we talking about again?' return result.text
def get_items_by_date(value, num): session = common.DBSession() query = session.query(Collection) query = query.filter_by(Collection.year == int(value)) query = query.limit(num) return query.all()
def get_items_by_keywords(value, num): session = common.DBSession() query = session.query(CollectionItem) query = query.filter(CollectionItem.story.like('%' + value + '%')) query = query.limit(num) return query.all()
def get_item_by_id(value): session = common.DBSession() query = session.query(CollectionItem) query = query.filter_by(id=value) return query.first()
def add_photo(photo): """ Used initially just to import data from csv into sqlite """ session = common.DBSession() session.add(photo)
def get_photos_by_keywords(value, num): session = common.DBSession() query = session.query(Photo) query = query.filter(Photo.story.like('%' + value + '%')) query = query.limit(num) return query.all()
def get_photo_by_id(value): session = common.DBSession() query = session.query(Photo) query.filter_by(id=value) return query.first()
def add_bert_speak(bert): """ Used initially just to import data from csv into sqlite """ session = common.DBSession() session.add(bert)
def get_items_by_keywords(value, num): session = common.DBSession() query = session.query(Picture) query = query.filter(Picture.description.like('%' + value + '%')) query = query.limit(num) return query.all()
def get_item_by_id(value): session = common.DBSession() query = session.query(Picture) query = query.filter_by(id=value) return query.first()
def add_museum(museum): """ Used initially just to import data from csv into sqlite """ session = common.DBSession() session.add(museum)