MCPcopy Index your code
hub / github.com/apache/cassandra-python-driver / one

Method one

cassandra/cluster.py:5229–5243  ·  view source on GitHub ↗

Return a single row of the results or None if empty. This is basically a shortcut to `result_set.current_rows[0]` and should only be used when you know a query returns a single row. Consider using an iterator if the ResultSet contains more than one row.

(self)

Source from the content-addressed store, hash-verified

5227 return list(self)
5228
5229 def one(self):
5230 """
5231 Return a single row of the results or None if empty. This is basically
5232 a shortcut to `result_set.current_rows[0]` and should only be used when
5233 you know a query returns a single row. Consider using an iterator if the
5234 ResultSet contains more than one row.
5235 """
5236 row = None
5237 if self._current_rows:
5238 try:
5239 row = self._current_rows[0]
5240 except TypeError: # generator object is not subscriptable, PYTHON-1026
5241 row = next(iter(self._current_rows))
5242
5243 return row
5244
5245 def __iter__(self):
5246 if self._list_mode:

Callers 11

test_oneMethod · 0.95
test_one_returns_noneMethod · 0.80
prepareMethod · 0.80
populateMethod · 0.80
check_appliedFunction · 0.80
countMethod · 0.80

Calls

no outgoing calls