Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cassandra/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ def default_retry_policy(self, policy):
cloud = None
"""
A dict of the cloud configuration. Example::

{
# path to the secure connect bundle
'secure_connect_bundle': '/path/to/secure-connect-dbname.zip',
Expand Down Expand Up @@ -1451,7 +1451,7 @@ def __init__(self, street, zipcode):
# results will include Address instances
results = session.execute("SELECT * FROM users")
row = results[0]
print row.id, row.location.street, row.location.zipcode
print(row.id, row.location.street, row.location.zipcode)

"""
if self.protocol_version < 3:
Expand Down
12 changes: 6 additions & 6 deletions cassandra/cqlengine/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ class ContextQuery(object):

with ContextQuery(Automobile, keyspace='test2') as A:
A.objects.create(manufacturer='honda', year=2008, model='civic')
print len(A.objects.all()) # 1 result
print(len(A.objects.all())) # 1 result

with ContextQuery(Automobile, keyspace='test4') as A:
print len(A.objects.all()) # 0 result
print(len(A.objects.all())) # 0 result

# Multiple models
with ContextQuery(Automobile, Automobile2, connection='cluster2') as (A, A2):
print len(A.objects.all())
print len(A2.objects.all())
print(len(A.objects.all()))
print(len(A2.objects.all()))

"""

Expand Down Expand Up @@ -809,11 +809,11 @@ class Comment(Model):

print("Normal")
for comment in Comment.objects(photo_id=u):
print comment.comment_id
print(comment.comment_id)

print("Reversed")
for comment in Comment.objects(photo_id=u).order_by("-comment_id"):
print comment.comment_id
print(comment.comment_id)
"""
if len(colnames) == 0:
clone = copy.deepcopy(self)
Expand Down
2 changes: 1 addition & 1 deletion cassandra/datastax/graph/fluent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def traversal_source(session=None, graph_name=None, execution_profile=EXEC_PROFI
session = c.connect()

g = DseGraph.traversal_source(session, 'my_graph')
print g.V().valueMap().toList()
print(g.V().valueMap().toList())

"""

Expand Down
10 changes: 5 additions & 5 deletions cassandra/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def tuple_factory(colnames, rows):
>>> session = cluster.connect('mykeyspace')
>>> session.row_factory = tuple_factory
>>> rows = session.execute("SELECT name, age FROM users LIMIT 1")
>>> print rows[0]
>>> print(rows[0])
('Bob', 42)

.. versionchanged:: 2.0.0
Expand Down Expand Up @@ -133,16 +133,16 @@ def named_tuple_factory(colnames, rows):
>>> user = rows[0]

>>> # you can access field by their name:
>>> print "name: %s, age: %d" % (user.name, user.age)
>>> print("name: %s, age: %d" % (user.name, user.age))
name: Bob, age: 42

>>> # or you can access fields by their position (like a tuple)
>>> name, age = user
>>> print "name: %s, age: %d" % (name, age)
>>> print("name: %s, age: %d" % (name, age))
name: Bob, age: 42
>>> name = user[0]
>>> age = user[1]
>>> print "name: %s, age: %d" % (name, age)
>>> print("name: %s, age: %d" % (name, age))
name: Bob, age: 42

.. versionchanged:: 2.0.0
Expand Down Expand Up @@ -188,7 +188,7 @@ def dict_factory(colnames, rows):
>>> session = cluster.connect('mykeyspace')
>>> session.row_factory = dict_factory
>>> rows = session.execute("SELECT name, age FROM users LIMIT 1")
>>> print rows[0]
>>> print(rows[0])
{u'age': 42, u'name': u'Bob'}

.. versionchanged:: 2.0.0
Expand Down
4 changes: 2 additions & 2 deletions docs/api/cassandra/cqlengine/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Model
TestIfNotExistsModel.if_not_exists().create(id=id, count=9, text='111111111111')
except LWTException as e:
# handle failure case
print e.existing # dict containing LWT result fields
print(e.existing # dict containing LWT result fields)

This method is supported on Cassandra 2.0 or later.

Expand Down Expand Up @@ -144,7 +144,7 @@ Model
t.iff(count=5).update('other text')
except LWTException as e:
# handle failure case
print e.existing # existing object
print(e.existing # existing object)

.. automethod:: get

Expand Down
2 changes: 1 addition & 1 deletion docs/cqlengine/connections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ You can specify a default connection per model:
year = columns.Integer(primary_key=True)
model = columns.Text(primary_key=True)

print len(Automobile.objects.all()) # executed on the connection 'cluster2'
print(len(Automobile.objects.all())) # executed on the connection 'cluster2'

QuerySet and model instance
---------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/cqlengine/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ are only created, presisted, and queried via table Models. A short example to in

users.create(name="Joe", addr=address(street="Easy St.", zipcode=99999))
user = users.objects(name="Joe")[0]
print user.name, user.addr
print(user.name, user.addr)
# Joe address(street=u'Easy St.', zipcode=99999)

UDTs are modeled by inheriting :class:`~.usertype.UserType`, and setting column type attributes. Types are then used in defining
Expand Down
14 changes: 7 additions & 7 deletions docs/execution_profiles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Default
session = cluster.connect()
local_query = 'SELECT rpc_address FROM system.local'
for _ in cluster.metadata.all_hosts():
print session.execute(local_query)[0]
print(session.execute(local_query)[0])


.. parsed-literal::
Expand All @@ -69,7 +69,7 @@ Initializing cluster with profiles
profiles = {'node1': node1_profile, 'node2': node2_profile}
session = Cluster(execution_profiles=profiles).connect()
for _ in cluster.metadata.all_hosts():
print session.execute(local_query, execution_profile='node1')[0]
print(session.execute(local_query, execution_profile='node1')[0])


.. parsed-literal::
Expand All @@ -81,7 +81,7 @@ Initializing cluster with profiles
.. code:: python

for _ in cluster.metadata.all_hosts():
print session.execute(local_query, execution_profile='node2')[0]
print(session.execute(local_query, execution_profile='node2')[0])


.. parsed-literal::
Expand All @@ -93,7 +93,7 @@ Initializing cluster with profiles
.. code:: python

for _ in cluster.metadata.all_hosts():
print session.execute(local_query)[0]
print(session.execute(local_query)[0])


.. parsed-literal::
Expand Down Expand Up @@ -123,7 +123,7 @@ New profiles can be added constructing from scratch, or deriving from default:
cluster.add_execution_profile(node1_profile, locked_execution)

for _ in cluster.metadata.all_hosts():
print session.execute(local_query, execution_profile=node1_profile)[0]
print(session.execute(local_query, execution_profile=node1_profile)[0])


.. parsed-literal::
Expand All @@ -144,8 +144,8 @@ We also have the ability to pass profile instances to be used for execution, but

tmp = session.execution_profile_clone_update('node1', request_timeout=100, row_factory=tuple_factory)

print session.execute(local_query, execution_profile=tmp)[0]
print session.execute(local_query, execution_profile='node1')[0]
print(session.execute(local_query, execution_profile=tmp)[0])
print(session.execute(local_query, execution_profile='node1')[0])

.. parsed-literal::

Expand Down
4 changes: 2 additions & 2 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Since tracing is done asynchronously to the request, this method polls until the
>>> result = future.result()
>>> trace = future.get_query_trace()
>>> for e in trace.events:
>>> print e.source_elapsed, e.description
>>> print(e.source_elapsed, e.description)

0:00:00.000077 Parsing select * from system.local
0:00:00.000153 Preparing statement
Expand All @@ -67,7 +67,7 @@ With prepared statements, the replicas are obtained by ``routing_key``, based on
>>> bound = prepared.bind((1,))
>>> replicas = cluster.metadata.get_replicas(bound.keyspace, bound.routing_key)
>>> for h in replicas:
>>> print h.address
>>> print(h.address)
127.0.0.1
127.0.0.2

Expand Down
12 changes: 6 additions & 6 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ way to execute a query is to use :meth:`~.Session.execute()`:

rows = session.execute('SELECT name, age, email FROM users')
for user_row in rows:
print user_row.name, user_row.age, user_row.email
print(user_row.name, user_row.age, user_row.email)

This will transparently pick a Cassandra node to execute the query against
and handle any retries that are necessary if the operation fails.
Expand All @@ -158,19 +158,19 @@ examples are equivalent:

rows = session.execute('SELECT name, age, email FROM users')
for row in rows:
print row.name, row.age, row.email
print(row.name, row.age, row.email)

.. code-block:: python

rows = session.execute('SELECT name, age, email FROM users')
for (name, age, email) in rows:
print name, age, email
print(name, age, email)

.. code-block:: python

rows = session.execute('SELECT name, age, email FROM users')
for row in rows:
print row[0], row[1], row[2]
print(row[0], row[1], row[2])

If you prefer another result format, such as a ``dict`` per row, you
can change the :attr:`~.Session.row_factory` attribute.
Expand Down Expand Up @@ -358,7 +358,7 @@ For example:
try:
rows = future.result()
user = rows[0]
print user.name, user.age
print(user.name, user.age)
except ReadTimeout:
log.exception("Query timed out:")

Expand All @@ -375,7 +375,7 @@ This works well for executing many queries concurrently:
# wait for them to complete and use the results
for future in futures:
rows = future.result()
print rows[0].name
print(rows[0].name)

Alternatively, instead of calling :meth:`~.ResponseFuture.result()`,
you can attach callback and errback functions through the
Expand Down
10 changes: 5 additions & 5 deletions docs/graph_fluent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ to accomplish this configuration:
session = cluster.connect()

g = DseGraph.traversal_source(session) # Build the GraphTraversalSource
print g.V().toList() # Traverse the Graph
print(g.V().toList()) # Traverse the Graph

Note that the execution profile created with :meth:`DseGraph.create_execution_profile <.datastax.graph.fluent.DseGraph.create_execution_profile>` cannot
be used for any groovy string queries.
Expand Down Expand Up @@ -231,11 +231,11 @@ Batch Queries

DSE Graph supports batch queries using a :class:`TraversalBatch <.datastax.graph.fluent.query.TraversalBatch>` object
instantiated with :meth:`DseGraph.batch <.datastax.graph.fluent.DseGraph.batch>`. A :class:`TraversalBatch <.datastax.graph.fluent.query.TraversalBatch>` allows
you to execute multiple graph traversals in a single atomic transaction. A
traversal batch is executed with :meth:`.Session.execute_graph` or using
:meth:`TraversalBatch.execute <.datastax.graph.fluent.query.TraversalBatch.execute>` if bounded to a DSE session.
you to execute multiple graph traversals in a single atomic transaction. A
traversal batch is executed with :meth:`.Session.execute_graph` or using
:meth:`TraversalBatch.execute <.datastax.graph.fluent.query.TraversalBatch.execute>` if bounded to a DSE session.

Either way you choose to execute the traversal batch, you need to configure
Either way you choose to execute the traversal batch, you need to configure
the execution profile accordingly. Here is a example::

from cassandra.cluster import Cluster
Expand Down
4 changes: 2 additions & 2 deletions docs/object_mapper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Getting Started
>>> q.count()
4
>>> for instance in q:
>>> print instance.description
>>> print(instance.description)
example5
example6
example7
Expand All @@ -101,5 +101,5 @@ Getting Started
>>> q2.count()
1
>>> for instance in q2:
>>> print instance.description
>>> print(instance.description)
example5