MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / register_connection

Function register_connection

mongoengine/connection.py:224–272  ·  view source on GitHub ↗

Register the connection settings. :param alias: the name that will be used to refer to this connection throughout MongoEngine :param db: the name of the database to use, for compatibility with connect :param name: the name of the specific database to use :param host: the host name o

(
    alias,
    db=None,
    name=None,
    host=None,
    port=None,
    read_preference=READ_PREFERENCE,
    username=None,
    password=None,
    authentication_source=None,
    authentication_mechanism=None,
    authmechanismproperties=None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

222
223
224def register_connection(
225 alias,
226 db=None,
227 name=None,
228 host=None,
229 port=None,
230 read_preference=READ_PREFERENCE,
231 username=None,
232 password=None,
233 authentication_source=None,
234 authentication_mechanism=None,
235 authmechanismproperties=None,
236 **kwargs,
237):
238 """Register the connection settings.
239
240 :param alias: the name that will be used to refer to this connection throughout MongoEngine
241 :param db: the name of the database to use, for compatibility with connect
242 :param name: the name of the specific database to use
243 :param host: the host name of the: program: `mongod` instance to connect to
244 :param port: the port that the: program: `mongod` instance is running on
245 :param read_preference: The read preference for the collection
246 :param username: username to authenticate with
247 :param password: password to authenticate with
248 :param authentication_source: database to authenticate against
249 :param authentication_mechanism: database authentication mechanisms.
250 By default, use SCRAM-SHA-1 with MongoDB 3.0 and later,
251 MONGODB-CR (MongoDB Challenge Response protocol) for older servers.
252 :param mongo_client_class: using alternative connection client other than
253 pymongo.MongoClient, e.g. mongomock, montydb, that provides pymongo alike
254 interface but not necessarily for connecting to a real mongo instance.
255 :param kwargs: ad-hoc parameters to be passed into the pymongo driver,
256 for example maxpoolsize, tz_aware, etc. See the documentation
257 for pymongo's `MongoClient` for a full list.
258 """
259 conn_settings = _get_connection_settings(
260 db=db,
261 name=name,
262 host=host,
263 port=port,
264 read_preference=read_preference,
265 username=username,
266 password=password,
267 authentication_source=authentication_source,
268 authentication_mechanism=authentication_mechanism,
269 authmechanismproperties=authmechanismproperties,
270 **kwargs,
271 )
272 _connection_settings[alias] = conn_settings
273
274
275def disconnect(alias=DEFAULT_CONNECTION_NAME):

Calls 1

_get_connection_settingsFunction · 0.85