Server: Connecting to CouchDB¶
-
class
couchdbreq.Server(uri='http://127.0.0.1:5984', session=None, timeout=5)[source]¶ A Server object represents the connection to the CouchDB database.
Parameters: - uri – URI of the server
- session – A
couchdbreq.Sessionobject. Use this to configure the connection parameters such as timeout, connection pool size and authentication.
-
create_db(dbname)[source]¶ Create a database on the server
Parameters: dbname – unicode name of the db Returns: couchdbreq.DatabaseRaise: couchdbreq.exceptions.DatabaseExistsExceptionIf the database already exists
-
get_db(dbname, is_verify_existance=True)[source]¶ Get a
couchdbreq.Databaseobject for an existing databaseIf the database does not exist and is_verify_existance=True then
couchdbreq.exceptions.ResourceNotFoundwill be raised.Parameters: - dbname – unicode name of the db
- is_verify_existance – bool Set to false to avoid a HEAD request checking that the database exists
Returns: couchdbreq.DatabaseRaise: couchdbreq.exceptions.ResourceNotFoundIf the database does not exist
-
get_or_create_db(dbname)[source]¶ Get a database or create new database if missing.
Parameters: dbname – unicode name of the db Returns: couchdbreq.Database
-
replicate(source, target, cancel=False, continuous=False, create_target=False, doc_ids=None, filter=None, proxy=None, query_params=None)[source]¶ Replicate a database
More info about replication here: http://wiki.apache.org/couchdb/Replication
Parameters: - source – URI or dbname of the source
- target – URI or dbname of the target