def query2(self, query, bindata=None):
"""
Alias for query method which make use of the python 'with' statement.
The contextmanager approach ensures that the generated cursor object instance
is always closed whenever the execution goes out of the 'with' statement block.
Example:
>> with self.console.storage.query(query) as cursor:
>> if not cursor.EOF:
>> cursor.getRow()
>> ...
:param query: The query to execute.
:param bindata: Data to bind to the given query.
"""
cursor = None
try:
cursor = self.query(query, bindata)
yield cursor
finally:
if cursor:
cursor.close()
评论列表
文章目录