fixes for consistency and setup -> native driver passthrough

This commit is contained in:
Jon Haddad
2014-06-23 12:27:46 -07:00
parent 41072658b9
commit 7779a03206
2 changed files with 13 additions and 8 deletions

View File

@@ -15,7 +15,7 @@ except ImportError:
import logging
from cqlengine.exceptions import CQLEngineException
from cassandra import ConsistencyLevel
from cqlengine.statements import BaseCQLStatement
from cassandra.query import dict_factory
@@ -27,16 +27,12 @@ Host = namedtuple('Host', ['name', 'port'])
cluster = None
session = None
class CQLConnectionError(CQLEngineException): pass
default_consistency_level = None
def setup(
hosts,
default_keyspace=None,
consistency='ONE',
timeout=None,
consistency=ConsistencyLevel.ONE,
**kwargs):
"""
Records the hosts and connects to one of them
@@ -55,16 +51,21 @@ def setup(
:type timeout: int or long
"""
global cluster, session
global cluster, session, default_consistency_level
if 'username' in kwargs or 'password' in kwargs:
raise CQLEngineException("Username & Password are now handled by using the native driver's auth_provider")
default_consistency_level = consistency
cluster = Cluster(hosts, **kwargs)
session = cluster.connect()
session.row_factory = dict_factory
def execute(query, params=None, consistency_level=None):
if consistency_level is None:
consistency_level = default_consistency_level
if isinstance(query, Statement):
pass

View File

@@ -7,3 +7,7 @@ If you're calling setup() with the old thrift port in place, you will get connec
The cqlengine connection pool has been removed. Connections are now managed by the native driver. This should drastically reduce the socket overhead as the native driver can multiplex queries.
If you were previously manually using "ALL", "QUORUM", etc, to specificy consistency levels, you will need to migrate to the cqlengine.ALL, QUORUM, etc instead. If you had been using the module level constants before, nothing should need to change.
No longer accepting username & password as arguments to setup. Use the native driver's authentication instead. See http://datastax.github.io/python-driver/api/cassandra/auth.html