Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-release > by-pkgid > bc55833f04f370ac3ed453ef5b0ad686 > files > 255

python2-gridfs-3.7.2-1.mga7.i586.rpm


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>mongo_replica_set_client – Tools for connecting to a MongoDB replica set &#8212; PyMongo 3.7.2 documentation</title>
    <link rel="stylesheet" href="../../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../../_static/sidebar.js"></script>
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="monitoring – Tools for monitoring driver events." href="monitoring.html" />
    <link rel="prev" title="mongo_client – Tools for connecting to MongoDB" href="mongo_client.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="monitoring.html" title="monitoring – Tools for monitoring driver events."
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="mongo_client.html" title="mongo_client – Tools for connecting to MongoDB"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">PyMongo 3.7.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >API Documentation</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U"><code class="docutils literal notranslate"><span class="pre">pymongo</span></code> – Python driver for MongoDB</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-pymongo.mongo_replica_set_client">
<span id="mongo-replica-set-client-tools-for-connecting-to-a-mongodb-replica-set"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">mongo_replica_set_client</span></code> – Tools for connecting to a MongoDB replica set<a class="headerlink" href="#module-pymongo.mongo_replica_set_client" title="Permalink to this headline">¶</a></h1>
<p>Deprecated. See <a class="reference internal" href="../../examples/high_availability.html"><span class="doc">High Availability and PyMongo</span></a>.</p>
<dl class="class">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient">
<em class="property">class </em><code class="descclassname">pymongo.mongo_replica_set_client.</code><code class="descname">MongoReplicaSetClient</code><span class="sig-paren">(</span><em>hosts_or_uri</em>, <em>document_class=dict</em>, <em>tz_aware=False</em>, <em>connect=True</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated alias for <a class="reference internal" href="mongo_client.html#pymongo.mongo_client.MongoClient" title="pymongo.mongo_client.MongoClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">MongoClient</span></code></a>.</p>
<p><a class="reference internal" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient" title="pymongo.mongo_replica_set_client.MongoReplicaSetClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">MongoReplicaSetClient</span></code></a>
will be removed in a future version of PyMongo.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.0: </span><a class="reference internal" href="mongo_client.html#pymongo.mongo_client.MongoClient" title="pymongo.mongo_client.MongoClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">MongoClient</span></code></a> is now the one and only
client class for a standalone server, mongos, or replica set.
It includes the functionality that had been split into
<a class="reference internal" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient" title="pymongo.mongo_replica_set_client.MongoReplicaSetClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">MongoReplicaSetClient</span></code></a>: it
can connect to a replica set, discover all its members, and monitor
the set for stepdowns, elections, and reconfigs.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">refresh</span></code> method is removed from
<a class="reference internal" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient" title="pymongo.mongo_replica_set_client.MongoReplicaSetClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">MongoReplicaSetClient</span></code></a>,
as are the <code class="docutils literal notranslate"><span class="pre">seeds</span></code> and <code class="docutils literal notranslate"><span class="pre">hosts</span></code> properties.</p>
</div>
<dl class="method">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Cleanup client resources and disconnect from MongoDB.</p>
<p>On MongoDB &gt;= 3.6, end all server sessions created by this client by
sending one or more endSessions commands.</p>
<p>Close all sockets in the connection pools and stop the monitor threads.
If this instance is used again it will be automatically re-opened and
the threads restarted.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.6: </span>End all server sessions created by this client.</p>
</div>
</dd></dl>

<dl class="describe">
<dt>
<code class="descname">c[db_name] || c.db_name</code></dt>
<dd><p>Get the <cite>db_name</cite> <a class="reference internal" href="database.html#pymongo.database.Database" title="pymongo.database.Database"><code class="xref py py-class docutils literal notranslate"><span class="pre">Database</span></code></a> on <a class="reference internal" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient" title="pymongo.mongo_replica_set_client.MongoReplicaSetClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">MongoReplicaSetClient</span></code></a> <cite>c</cite>.</p>
<p>Raises <a class="reference internal" href="errors.html#pymongo.errors.InvalidName" title="pymongo.errors.InvalidName"><code class="xref py py-class docutils literal notranslate"><span class="pre">InvalidName</span></code></a> if an invalid database name is used.</p>
</dd></dl>

<dl class="attribute">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.primary">
<code class="descname">primary</code><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.primary" title="Permalink to this definition">¶</a></dt>
<dd><p>The (host, port) of the current primary of the replica set.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">None</span></code> if this client is not connected to a replica set,
there is no primary, or this client was created without the
<cite>replicaSet</cite> option.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.0: </span>MongoClient gained this property in version 3.0 when
MongoReplicaSetClient’s functionality was merged in.</p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.secondaries">
<code class="descname">secondaries</code><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.secondaries" title="Permalink to this definition">¶</a></dt>
<dd><p>The secondary members known to this client.</p>
<p>A sequence of (host, port) pairs. Empty if this client is not
connected to a replica set, there are no visible secondaries, or this
client was created without the <cite>replicaSet</cite> option.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.0: </span>MongoClient gained this property in version 3.0 when
MongoReplicaSetClient’s functionality was merged in.</p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.arbiters">
<code class="descname">arbiters</code><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.arbiters" title="Permalink to this definition">¶</a></dt>
<dd><p>Arbiters in the replica set.</p>
<p>A sequence of (host, port) pairs. Empty if this client is not
connected to a replica set, there are no arbiters, or this client was
created without the <cite>replicaSet</cite> option.</p>
</dd></dl>

<dl class="attribute">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.max_pool_size">
<code class="descname">max_pool_size</code><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.max_pool_size" title="Permalink to this definition">¶</a></dt>
<dd><p>The maximum allowable number of concurrent connections to each
connected server. Requests to a server will block if there are
<cite>maxPoolSize</cite> outstanding connections to the requested server.
Defaults to 100. Cannot be 0.</p>
<p>When a server’s pool has reached <cite>max_pool_size</cite>, operations for that
server block waiting for a socket to be returned to the pool. If
<code class="docutils literal notranslate"><span class="pre">waitQueueTimeoutMS</span></code> is set, a blocked operation will raise
<a class="reference internal" href="errors.html#pymongo.errors.ConnectionFailure" title="pymongo.errors.ConnectionFailure"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionFailure</span></code></a> after a timeout.
By default <code class="docutils literal notranslate"><span class="pre">waitQueueTimeoutMS</span></code> is not set.</p>
</dd></dl>

<dl class="attribute">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.max_bson_size">
<code class="descname">max_bson_size</code><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.max_bson_size" title="Permalink to this definition">¶</a></dt>
<dd><p>The largest BSON object the connected server accepts in bytes.</p>
<p>If the client is not connected, this will block until a connection is
established or raise ServerSelectionTimeoutError if no server is
available.</p>
</dd></dl>

<dl class="attribute">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.max_message_size">
<code class="descname">max_message_size</code><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.max_message_size" title="Permalink to this definition">¶</a></dt>
<dd><p>The largest message the connected server accepts in bytes.</p>
<p>If the client is not connected, this will block until a connection is
established or raise ServerSelectionTimeoutError if no server is
available.</p>
</dd></dl>

<dl class="attribute">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.local_threshold_ms">
<code class="descname">local_threshold_ms</code><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.local_threshold_ms" title="Permalink to this definition">¶</a></dt>
<dd><p>The local threshold for this instance.</p>
</dd></dl>

<dl class="attribute">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.codec_options">
<code class="descname">codec_options</code><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.codec_options" title="Permalink to this definition">¶</a></dt>
<dd><p>Read only access to the <a class="reference internal" href="../bson/codec_options.html#bson.codec_options.CodecOptions" title="bson.codec_options.CodecOptions"><code class="xref py py-class docutils literal notranslate"><span class="pre">CodecOptions</span></code></a>
of this instance.</p>
</dd></dl>

<dl class="attribute">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.read_preference">
<code class="descname">read_preference</code><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.read_preference" title="Permalink to this definition">¶</a></dt>
<dd><p>Read only access to the read preference of this instance.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.0: </span>The <a class="reference internal" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.read_preference" title="pymongo.mongo_replica_set_client.MongoReplicaSetClient.read_preference"><code class="xref py py-attr docutils literal notranslate"><span class="pre">read_preference</span></code></a> attribute is now read only.</p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.write_concern">
<code class="descname">write_concern</code><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.write_concern" title="Permalink to this definition">¶</a></dt>
<dd><p>Read only access to the <a class="reference internal" href="write_concern.html#pymongo.write_concern.WriteConcern" title="pymongo.write_concern.WriteConcern"><code class="xref py py-class docutils literal notranslate"><span class="pre">WriteConcern</span></code></a>
of this instance.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.0: </span>The <a class="reference internal" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.write_concern" title="pymongo.mongo_replica_set_client.MongoReplicaSetClient.write_concern"><code class="xref py py-attr docutils literal notranslate"><span class="pre">write_concern</span></code></a> attribute is now read only.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.database_names">
<code class="descname">database_names</code><span class="sig-paren">(</span><em>session=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.database_names" title="Permalink to this definition">¶</a></dt>
<dd><p><strong>DEPRECATED</strong>: Get a list of the names of all databases on the
connected server.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>session</cite> (optional): a
<a class="reference internal" href="client_session.html#pymongo.client_session.ClientSession" title="pymongo.client_session.ClientSession"><code class="xref py py-class docutils literal notranslate"><span class="pre">ClientSession</span></code></a>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.7: </span>Deprecated. Use <code class="xref py py-meth docutils literal notranslate"><span class="pre">list_database_names()</span></code> instead.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.6: </span>Added <code class="docutils literal notranslate"><span class="pre">session</span></code> parameter.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.drop_database">
<code class="descname">drop_database</code><span class="sig-paren">(</span><em>name_or_database</em>, <em>session=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.drop_database" title="Permalink to this definition">¶</a></dt>
<dd><p>Drop a database.</p>
<p>Raises <code class="xref py py-class docutils literal notranslate"><span class="pre">TypeError</span></code> if <cite>name_or_database</cite> is not an instance of
<code class="xref py py-class docutils literal notranslate"><span class="pre">basestring</span></code> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code> in python 3) or
<a class="reference internal" href="database.html#pymongo.database.Database" title="pymongo.database.Database"><code class="xref py py-class docutils literal notranslate"><span class="pre">Database</span></code></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>name_or_database</cite>: the name of a database to drop, or a
<a class="reference internal" href="database.html#pymongo.database.Database" title="pymongo.database.Database"><code class="xref py py-class docutils literal notranslate"><span class="pre">Database</span></code></a> instance representing the
database to drop</li>
<li><cite>session</cite> (optional): a
<a class="reference internal" href="client_session.html#pymongo.client_session.ClientSession" title="pymongo.client_session.ClientSession"><code class="xref py py-class docutils literal notranslate"><span class="pre">ClientSession</span></code></a>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.6: </span>Added <code class="docutils literal notranslate"><span class="pre">session</span></code> parameter.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <a class="reference internal" href="mongo_client.html#pymongo.mongo_client.MongoClient.write_concern" title="pymongo.mongo_client.MongoClient.write_concern"><code class="xref py py-attr docutils literal notranslate"><span class="pre">write_concern</span></code></a> of
this client is automatically applied to this operation when using
MongoDB &gt;= 3.4.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Apply this client’s write concern automatically to this operation
when connected to MongoDB &gt;= 3.4.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.get_database">
<code class="descname">get_database</code><span class="sig-paren">(</span><em>name=None</em>, <em>codec_options=None</em>, <em>read_preference=None</em>, <em>write_concern=None</em>, <em>read_concern=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.get_database" title="Permalink to this definition">¶</a></dt>
<dd><p>Get a <a class="reference internal" href="database.html#pymongo.database.Database" title="pymongo.database.Database"><code class="xref py py-class docutils literal notranslate"><span class="pre">Database</span></code></a> with the given name and
options.</p>
<p>Useful for creating a <a class="reference internal" href="database.html#pymongo.database.Database" title="pymongo.database.Database"><code class="xref py py-class docutils literal notranslate"><span class="pre">Database</span></code></a> with
different codec options, read preference, and/or write concern from
this <code class="xref py py-class docutils literal notranslate"><span class="pre">MongoClient</span></code>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">client</span><span class="o">.</span><span class="n">read_preference</span>
<span class="go">Primary()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">db1</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">test</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">db1</span><span class="o">.</span><span class="n">read_preference</span>
<span class="go">Primary()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pymongo</span> <span class="k">import</span> <span class="n">ReadPreference</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">db2</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_database</span><span class="p">(</span>
<span class="gp">... </span>    <span class="s1">&#39;test&#39;</span><span class="p">,</span> <span class="n">read_preference</span><span class="o">=</span><span class="n">ReadPreference</span><span class="o">.</span><span class="n">SECONDARY</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">db2</span><span class="o">.</span><span class="n">read_preference</span>
<span class="go">Secondary(tag_sets=None)</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>name</cite> (optional): The name of the database - a string. If <code class="docutils literal notranslate"><span class="pre">None</span></code>
(the default) the database named in the MongoDB connection URI is
returned.</li>
<li><cite>codec_options</cite> (optional): An instance of
<a class="reference internal" href="../bson/codec_options.html#bson.codec_options.CodecOptions" title="bson.codec_options.CodecOptions"><code class="xref py py-class docutils literal notranslate"><span class="pre">CodecOptions</span></code></a>. If <code class="docutils literal notranslate"><span class="pre">None</span></code> (the
default) the <a class="reference internal" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.codec_options" title="pymongo.mongo_replica_set_client.MongoReplicaSetClient.codec_options"><code class="xref py py-attr docutils literal notranslate"><span class="pre">codec_options</span></code></a> of this <code class="xref py py-class docutils literal notranslate"><span class="pre">MongoClient</span></code> is
used.</li>
<li><cite>read_preference</cite> (optional): The read preference to use. If
<code class="docutils literal notranslate"><span class="pre">None</span></code> (the default) the <a class="reference internal" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.read_preference" title="pymongo.mongo_replica_set_client.MongoReplicaSetClient.read_preference"><code class="xref py py-attr docutils literal notranslate"><span class="pre">read_preference</span></code></a> of this
<code class="xref py py-class docutils literal notranslate"><span class="pre">MongoClient</span></code> is used. See <a class="reference internal" href="read_preferences.html#module-pymongo.read_preferences" title="pymongo.read_preferences: Utilities for choosing which member of a replica set to read from."><code class="xref py py-mod docutils literal notranslate"><span class="pre">read_preferences</span></code></a>
for options.</li>
<li><cite>write_concern</cite> (optional): An instance of
<a class="reference internal" href="write_concern.html#pymongo.write_concern.WriteConcern" title="pymongo.write_concern.WriteConcern"><code class="xref py py-class docutils literal notranslate"><span class="pre">WriteConcern</span></code></a>. If <code class="docutils literal notranslate"><span class="pre">None</span></code> (the
default) the <a class="reference internal" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.write_concern" title="pymongo.mongo_replica_set_client.MongoReplicaSetClient.write_concern"><code class="xref py py-attr docutils literal notranslate"><span class="pre">write_concern</span></code></a> of this <code class="xref py py-class docutils literal notranslate"><span class="pre">MongoClient</span></code> is
used.</li>
<li><cite>read_concern</cite> (optional): An instance of
<a class="reference internal" href="read_concern.html#pymongo.read_concern.ReadConcern" title="pymongo.read_concern.ReadConcern"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReadConcern</span></code></a>. If <code class="docutils literal notranslate"><span class="pre">None</span></code> (the
default) the <code class="xref py py-attr docutils literal notranslate"><span class="pre">read_concern</span></code> of this <code class="xref py py-class docutils literal notranslate"><span class="pre">MongoClient</span></code> is
used.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.5: </span>The <cite>name</cite> parameter is now optional, defaulting to the database
named in the MongoDB connection URI.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.close_cursor">
<code class="descname">close_cursor</code><span class="sig-paren">(</span><em>cursor_id</em>, <em>address=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.close_cursor" title="Permalink to this definition">¶</a></dt>
<dd><p>DEPRECATED - Send a kill cursors message soon with the given id.</p>
<p>Raises <code class="xref py py-class docutils literal notranslate"><span class="pre">TypeError</span></code> if <cite>cursor_id</cite> is not an instance of
<code class="docutils literal notranslate"><span class="pre">(int,</span> <span class="pre">long)</span></code>. What closing the cursor actually means
depends on this client’s cursor manager.</p>
<p>This method may be called from a <a class="reference internal" href="cursor.html#pymongo.cursor.Cursor" title="pymongo.cursor.Cursor"><code class="xref py py-class docutils literal notranslate"><span class="pre">Cursor</span></code></a>
destructor during garbage collection, so it isn’t safe to take a
lock or do network I/O. Instead, we schedule the cursor to be closed
soon on a background thread.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>cursor_id</cite>: id of cursor to close</li>
<li><cite>address</cite> (optional): (host, port) pair of the cursor’s server.
If it is not provided, the client attempts to close the cursor on
the primary or standalone, or a mongos server.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.7: </span>Deprecated.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.0: </span>Added <code class="docutils literal notranslate"><span class="pre">address</span></code> parameter.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.kill_cursors">
<code class="descname">kill_cursors</code><span class="sig-paren">(</span><em>cursor_ids</em>, <em>address=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.kill_cursors" title="Permalink to this definition">¶</a></dt>
<dd><p>DEPRECATED - Send a kill cursors message soon with the given ids.</p>
<p>Raises <code class="xref py py-class docutils literal notranslate"><span class="pre">TypeError</span></code> if <cite>cursor_ids</cite> is not an instance of
<code class="docutils literal notranslate"><span class="pre">list</span></code>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>cursor_ids</cite>: list of cursor ids to kill</li>
<li><cite>address</cite> (optional): (host, port) pair of the cursor’s server.
If it is not provided, the client attempts to close the cursor on
the primary or standalone, or a mongos server.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.3: </span>Deprecated.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.0: </span>Now accepts an <cite>address</cite> argument. Schedules the cursors to be
closed on a background thread instead of sending the message
immediately.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.set_cursor_manager">
<code class="descname">set_cursor_manager</code><span class="sig-paren">(</span><em>manager_class</em><span class="sig-paren">)</span><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.set_cursor_manager" title="Permalink to this definition">¶</a></dt>
<dd><p>DEPRECATED - Set this client’s cursor manager.</p>
<p>Raises <code class="xref py py-class docutils literal notranslate"><span class="pre">TypeError</span></code> if <cite>manager_class</cite> is not a subclass of
<a class="reference internal" href="cursor_manager.html#pymongo.cursor_manager.CursorManager" title="pymongo.cursor_manager.CursorManager"><code class="xref py py-class docutils literal notranslate"><span class="pre">CursorManager</span></code></a>. A cursor manager
handles closing cursors. Different managers can implement different
policies in terms of when to actually kill a cursor that has
been closed.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><cite>manager_class</cite>: cursor manager to use</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.3: </span>Deprecated, for real this time.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.0: </span>Undeprecated.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pymongo.mongo_replica_set_client.MongoReplicaSetClient.get_default_database">
<code class="descname">get_default_database</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.get_default_database" title="Permalink to this definition">¶</a></dt>
<dd><p>DEPRECATED - Get the database named in the MongoDB connection URI.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">uri</span> <span class="o">=</span> <span class="s1">&#39;mongodb://host/my_database&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">client</span> <span class="o">=</span> <span class="n">MongoClient</span><span class="p">(</span><span class="n">uri</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">db</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_default_database</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">assert</span> <span class="n">db</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s1">&#39;my_database&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">db</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_database</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">assert</span> <span class="n">db</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s1">&#39;my_database&#39;</span>
</pre></div>
</div>
<p>Useful in scripts where you want to choose which database to use
based only on the URI in a configuration file.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.5: </span>Deprecated, use <a class="reference internal" href="#pymongo.mongo_replica_set_client.MongoReplicaSetClient.get_database" title="pymongo.mongo_replica_set_client.MongoReplicaSetClient.get_database"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_database()</span></code></a> instead.</p>
</div>
</dd></dl>

</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="mongo_client.html"
                        title="previous chapter"><code class="docutils literal notranslate"><span class="pre">mongo_client</span></code> – Tools for connecting to MongoDB</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="monitoring.html"
                        title="next chapter"><code class="docutils literal notranslate"><span class="pre">monitoring</span></code> – Tools for monitoring driver events.</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/api/pymongo/mongo_replica_set_client.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="monitoring.html" title="monitoring – Tools for monitoring driver events."
             >next</a> |</li>
        <li class="right" >
          <a href="mongo_client.html" title="mongo_client – Tools for connecting to MongoDB"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">PyMongo 3.7.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >API Documentation</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" ><code class="docutils literal notranslate"><span class="pre">pymongo</span></code> – Python driver for MongoDB</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright MongoDB, Inc. 2008-present. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc.
    </div>
  </body>
</html>