Skip to content
Closed
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
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Bug Fixes
* Driver deadlock if all connections dropped by heartbeat whilst request in flight and request times out (PYTHON-1044)
* Exception when use pk__token__gt filter In python 3.7 (PYTHON-1121)

Other
-----

* Convert print statement to print function in docs and comments

3.19.0
======
August 26, 2019
Expand Down
2 changes: 1 addition & 1 deletion cassandra/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,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
10 changes: 5 additions & 5 deletions cassandra/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,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 @@ -132,16 +132,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 @@ -187,7 +187,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 @@ -104,7 +104,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 @@ -145,7 +145,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
18 changes: 9 additions & 9 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 @@ -121,9 +121,9 @@ New profiles can be added constructing from scratch, or deriving from default:
locked_execution = ExecutionProfile(load_balancing_policy=WhiteListRoundRobinPolicy(['127.0.0.1']))
node1_profile = 'node1_whitelist'
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 @@ -141,11 +141,11 @@ We also have the ability to pass profile instances to be used for execution, but
.. code:: python

from cassandra.query import tuple_factory

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 @@ -87,7 +87,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 @@ -103,19 +103,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 @@ -271,7 +271,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 @@ -288,7 +288,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
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Verifying your Installation
---------------------------
To check if the installation was successful, you can run::

python -c 'import cassandra; print cassandra.__version__'
python -c 'import cassandra; print(cassandra.__version__)'

It should print something like "2.7.0".

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
4 changes: 2 additions & 2 deletions docs/user_defined_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ instance through :meth:`.Cluster.register_user_type`:
# 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)

Using UDTs Without Registering Them
-----------------------------------
Expand Down Expand Up @@ -79,7 +79,7 @@ for the UDT:
results = session.execute("SELECT * FROM users")
first_row = results[0]
address = first_row.location
print address # prints "Address(street='123 Main St.', zipcode=78723)"
print(address) # prints "Address(street='123 Main St.', zipcode=78723)"
street = address.street
zipcode = address.street

Expand Down