Beispiel #1
0
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)
Beispiel #2
0
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
Beispiel #3
0
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
Beispiel #4
0
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()
Beispiel #5
0
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()
Beispiel #6
0
def get_item_by_id(value):
    session = common.DBSession()
    query = session.query(CollectionItem)
    query = query.filter_by(id=value)
    return query.first()
Beispiel #7
0
def add_photo(photo):
    """
    Used initially just to import data from csv into sqlite
    """
    session = common.DBSession()
    session.add(photo)
Beispiel #8
0
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()
Beispiel #9
0
def get_photo_by_id(value):
    session = common.DBSession()
    query = session.query(Photo)
    query.filter_by(id=value)
    return query.first()
Beispiel #10
0
def add_bert_speak(bert):
    """
    Used initially just to import data from csv into sqlite
    """
    session = common.DBSession()
    session.add(bert)
Beispiel #11
0
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()
Beispiel #12
0
def get_item_by_id(value):
    session = common.DBSession()
    query = session.query(Picture)
    query = query.filter_by(id=value)
    return query.first()
Beispiel #13
0
def add_museum(museum):
    """
    Used initially just to import data from csv into sqlite
    """
    session = common.DBSession()
    session.add(museum)