本文整理汇总了Python中models.Photo.desc方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.desc方法的具体用法?Python Photo.desc怎么用?Python Photo.desc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Photo
的用法示例。
在下文中一共展示了Photo.desc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_item
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import desc [as 别名]
def save_item(item, update_desc=False):
baidu_id = item.get('id')
if baidu_id is None:
return
session = DB_Session()
photo = session.query(Photo).filter(Photo.baidu_id==baidu_id).first()
if not photo:
photo = Photo(baidu_id=baidu_id,
photo_id=item['photo_id'],
image_url = item['image_url'],
image_width = item['image_width'],
image_height = item['image_height'],
thumbnail_url = item['thumbnail_url'],
thumbnail_width = item['thumbnail_width'],
thumbnail_height = item['thumbnail_height'],
thumb_large_url = item['thumb_large_url'],
thumb_large_width = item['thumb_large_width'],
thumb_large_height = item['thumb_large_height'],
from_url = item['from_url'],
obj_url = item['obj_url'],
desc = item['desc'],
image_date = item['date'],
insert_date = datetime.datetime.now()
)
session.add(photo)
session.commit()
logging.warn("add one item-%s" % photo.id)
elif update_desc:
photo.desc = item['desc']
session.commit()
logging.warn("update one item-%s" % photo.id)
session.close()