cassandra.cqlengine.connection - Connection management for cqlengine¶
-
cassandra.cqlengine.connection.default()[source]¶ Configures the default connection to localhost, using the driver defaults (except for row_factory)
-
cassandra.cqlengine.connection.set_session(s)[source]¶ Configures the default connection with a preexisting
cassandra.cluster.SessionNote: the mapper presently requires a Session
row_factoryset todict_factory. This may be relaxed in the future
-
cassandra.cqlengine.connection.setup(hosts, default_keyspace, consistency=None, lazy_connect=False, retry_connect=False, **kwargs)[source]¶ Setup a the driver connection used by the mapper
- Parameters
hosts (list) – list of hosts, (
contact_pointsforcassandra.cluster.Cluster)default_keyspace (str) – The default keyspace to use
consistency (int) – The global default
ConsistencyLevel- default is the same asSession.default_consistency_levellazy_connect (bool) – True if should not connect until first use
retry_connect (bool) – True if we should retry to connect even if there was a connection failure initially
**kwargs – Pass-through keyword arguments for
cassandra.cluster.Cluster
-
cassandra.cqlengine.connection.register_connection(name, hosts=None, consistency=None, lazy_connect=False, retry_connect=False, cluster_options=None, default=False, session=None)[source]¶ Add a connection to the connection registry.
hostsandsessionare mutually exclusive, andconsistency,lazy_connect,retry_connect, andcluster_optionsonly work withhosts. Usinghostswill create a newcassandra.cluster.Clusterandcassandra.cluster.Session.- Parameters
hosts (list) – list of hosts, (
contact_pointsforcassandra.cluster.Cluster).consistency (int) – The default
ConsistencyLevelfor the registered connection’s new session. Default is the same asSession.default_consistency_level. For use withhostsonly; will fail when used withsession.lazy_connect (bool) – True if should not connect until first use. For use with
hostsonly; will fail when used withsession.retry_connect (bool) – True if we should retry to connect even if there was a connection failure initially. For use with
hostsonly; will fail when used withsession.cluster_options (dict) – A dict of options to be used as keyword arguments to
cassandra.cluster.Cluster. For use withhostsonly; will fail when used withsession.default (bool) – If True, set the new connection as the cqlengine default
session (Session) – A
cassandra.cluster.Sessionto be used in the created connection.