| Trees | Indices | Help |
|
|---|
|
|
object --+
|
Connection
| Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
| Class Methods | |||
|
|||
| Class Variables | |
HOST =
|
|
PORT = 27017
|
|
POOL_SIZE = 1
|
|
AUTO_START_REQUEST = True
|
|
TIMEOUT = 1.0
|
|
| Properties | |
|
slave_okay Is it okay for this connection to connect directly to a slave? |
|
|
Inherited from |
|
| Method Details |
Open a new connection to a Mongo instance at host:port. The resultant connection object has connection-pooling built in. It also performs auto-reconnection when necessary. If an operation fails because of a connection error, pymongo.errors.ConnectionFailure is raised. If auto-reconnection will be performed, pymongo.errors.AutoReconnect will be raised. Application code should handle this exception (recognizing that the operation failed) and then continue to execute. Raises TypeError if host is not an instance of string or port is not an
instance of int. Raises ConnectionFailure if the connection cannot be
made. Raises TypeError if NOTE: Connection pooling is not compatible with auth (yet). Please do not set the "pool_size" to anything other than 1 if auth is in use.
|
Open a new paired connection to Mongo. Raises TypeError if either |
Set this connection's cursor manager. Raises TypeError if manager_class is not a subclass of CursorManager. 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.
|
Start a "request". A "request" is a group of operations in which order matters. Examples include inserting a document and then performing a query which expects that document to have been inserted, or performing an operation and then using database.Database.error() to perform error-checking on that operation. When a thread performs operations in a "request", the connection will perform all operations on the same socket, so Mongo will order them correctly. This method is only relevant when the current Connection has a "pool_size" greater than one. Otherwise only a single socket will be used for all operations, so there is no need to group operations into requests. This method only needs to be used if the "auto_start_request" option is set to False. If "auto_start_request" is True, a request will be started (if necessary) on every operation. |
End the current "request", if this thread is in one. Judicious use of this method can lead to performance gains when connection-pooling is being used. By ending a request when it is safe to do so the connection is allowed to pick a new socket from the pool for that thread on the next operation. This could prevent an imbalance of threads trying to connect on the same socket. Care should be taken, however, to make sure that end_request isn't called in the middle of a sequence of operations in which ordering is important. This could lead to unexpected results. end_request is useful even (especially) if "auto_start_request" is True. See the documentation for start_request for more information on what a "request" is and when one should be used. |
|
Get a database by name. Raises InvalidName if an invalid database name is used.
|
Get a database by name. Raises InvalidName if an invalid database name is used.
|
Close a single database cursor. Raises TypeError if cursor_id is not an instance of (int, long). What closing the cursor actually means depends on this connection's cursor manager.
|
Kill database cursors with the given ids. Raises TypeError if cursor_ids is not an instance of list.
|
|
| Property Details |
slave_okayIs it okay for this connection to connect directly to a slave?
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Sep 23 14:05:20 2009 | http://epydoc.sourceforge.net |