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.Session object. Use this to configure the connection parameters such as timeout, connection pool size and authentication.
active_tasks()[source]

return active tasks

create_db(dbname)[source]

Create a database on the server

Parameters:dbname – unicode name of the db
Returns:couchdbreq.Database
Raise:couchdbreq.exceptions.DatabaseExistsException If the database already exists
get_db(dbname, is_verify_existance=True)[source]

Get a couchdbreq.Database object for an existing database

If the database does not exist and is_verify_existance=True then couchdbreq.exceptions.ResourceNotFound will 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.Database

Raise:

couchdbreq.exceptions.ResourceNotFound If the database does not exist

get_db_names()[source]

Get all database names on the server

Returns:List of unicode database names
get_dbs()[source]

Iterate over all databases

Returns:List of couchdbreq.Database objects
get_info()[source]

Get server info

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
class couchdbreq.Session[source]

Bases: requests.sessions.Session

The http session for a server to use.

See http://docs.python-requests.org/en/latest/api/#sessionapi.