query.py

Go to the documentation of this file.
00001 import sys
00002 
00003 from vyperlogix.misc import _utils
00004 
00005 from vyperlogix.sql.sqlalchemy import SQLAgent
00006 
00007 def get_qry_by_parts(qry,callback=None):
00008     items = []
00009     try:
00010         num_items = qry.count()
00011         one_percent = (num_items / 100)
00012         if (one_percent < 200):
00013             one_percent = 200
00014         num_items_part = one_percent if (num_items > 10000) else num_items
00015         for i in xrange(num_items):
00016             item = SQLAgent.instance_as_SmartObject(qry[i])
00017             items.append(item)
00018             if (i > 0) and ((i % num_items_part) == 0):
00019                 if (callable(callback)):
00020                     try:
00021                         callback(items)
00022                     finally:
00023                         items = []
00024         if (len(items) > 0):
00025             if (callable(callback)):
00026                 try:
00027                     callback(items)
00028                 finally:
00029                     items = []
00030     except Exception, details:
00031         print >>sys.stderr, _utils.formattedException(details=details)
00032     return items
00033 
00034 
00035 

© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved; If you reference this document or any part of this document you must use the citation verbatim (including the link) "© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved."

Notice: This source code contained in this document is NOT open source and is NOT being distributed as open source.

122,241 lines of code and growing...