本文整理汇总了Python中dao.Dao.close方法的典型用法代码示例。如果您正苦于以下问题:Python Dao.close方法的具体用法?Python Dao.close怎么用?Python Dao.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dao.Dao
的用法示例。
在下文中一共展示了Dao.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calc
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import close [as 别名]
def calc(self, db):
def on_each_transaction(instrument, name, transaction_type, price, shares, fee, the_date):
pos = self.positions[instrument]
pos.transaction(transaction_type, price, shares, fee)
if isinstance(db, Dao):
d = db
close_db = False
else:
d = Dao(db)
close_db = True
self.positions = d.populate_from_instruments('(i.type = 2 or i.type = 1)',
lambda instrument_id, name, tid, t, u, e: Position(instrument_id,
name))
d.iterate_transaction(self.date1, self.date2, on_each_transaction)
if close_db:
d.close()
示例2: cmdline_args
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import close [as 别名]
return Report.to_json_packed({'data': q})
if __name__ == "__main__":
# import codecs,locale
# sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
args, others = cmdline_args(sys.argv[1:])
db = args['dbfile']
if db is None:
print 'Need a db file'
else:
dao = Dao(db)
if 'stock' in others:
r = StockReport(dao, args['end_date'])
print r.to_json(r.stock_positions())
elif 'fund' in others:
r = FundReport(dao, args['end_date'])
elif 'quote' in others:
print Report.to_json(raw_quote(dao))
elif 'xccy' in others:
print Report.to_json(raw_xccy(dao))
elif 'trans' in others:
print Report.to_json(raw_trans(dao))
elif 'sum' in others:
r = SummaryReport(dao, args['end_date'])
print Report.to_json(r.report(dao))
dao.close()