本文整理汇总了Python中quanthistling.model.meta.Session.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Session.execute方法的具体用法?Python Session.execute怎么用?Python Session.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quanthistling.model.meta.Session
的用法示例。
在下文中一共展示了Session.execute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from quanthistling.model.meta import Session [as 别名]
# 或者: from quanthistling.model.meta.Session import execute [as 别名]
def main(argv):
bibtex_key = u"morse1999"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
cmd = """\
delete from annotation
using book tb, entry te
where tb.bibtex_key = :bibtex_key and tb.id = te.book_id and te.id = entry_id
and annotationtype_id = (select id from annotationtype where type = 'dictinterpretation')"""
Session.execute(cmd, dict(bibtex_key=bibtex_key))
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=21,pos_on_page=12).all()
startletters = set()
for e in entries:
heads = annotate_everything(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
#annotate_dialect(e)
#annotate_pos(e)
#annotate_translations(e)
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()