couchdb.client.Server

Package couchdb :: Module client :: Class Server |

# Class Server

    object --+
             |
            Server

Representation of a CouchDB server.

    >>> server = Server('http://localhost:5984/')

This class behaves like a dictionary of databases. For example, to get a list of database names on the server, you can simply iterate over the server object.

New databases can be created using the create method:

    >>> db = server.create('python-tests')
    >>> db
    <Database 'python-tests'>

You can access existing databases using item access, specifying the database name as the key:

    >>> db = server['python-tests']
    >>> db.name
    'python-tests'

Databases can be deleted using a `del` statement:

    >>> del server['python-tests']

Instance Methods
__init__(self, uri=`'``http://localhost:5984/``'`, cache=None, timeout=None) Initialize the server object. |
__contains__(self, name) Return whether the server contains a database with the specified name. |
__iter__(self) Iterate over the names of all databases. |
__len__(self) Return the number of databases. |
__nonzero__(self) Return whether the server is available. |
__repr__(self) repr(x) |
__delitem__(self, name) Remove the database with the specified name. |
Database |
__getitem__(self, name) Return a Database object representing the database with the specified name. |
stats(self) Database statistics. |
tasks(self) A list of tasks currently active on the server. |
Database |
create(self, name) Create a new database with the given name. |
delete(self, name) Delete the database with the specified name. |
replicate(self, source, target, **options) Replicate changes from the source database to the target database. |
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
`dict` | config The configuration of the CouchDB server.
`unicode` | version The version string of the CouchDB server.
Inherited from `object`: `__class__`

Method Details

### __init__(self, uri=`'``http://localhost:5984/``'`, cache=None, timeout=None) (Constructor) |
Initialize the server object. Parameters: `uri` - the URI of the server (for example `http://localhost:5984/`) `cache` - either a cache directory path (as a string) or an object compatible with the `httplib2.FileCache` interface. If `None` (the default), no caching is performed. `timeout` - socket timeout in number of seconds, or `None` for no timeout Overrides: object.__init__

### __contains__(self, name) (In operator) |
Return whether the server contains a database with the specified name. Parameters: `name` - the database name Returns: `True` if a database with the name exists, `False` otherwise

### __repr__(self) (Representation operator) |
repr(x) Overrides: object.__repr__ (inherited documentation)

### __delitem__(self, name) (Index deletion operator) |
Remove the database with the specified name. Parameters: `name` - the name of the database Raises: `ResourceNotFound` - if no database with that name exists

### __getitem__(self, name) (Indexing operator) |
Return a Database object representing the database with the specified name. Parameters: `name` - the name of the database Returns: Database a Database object representing the database Raises: `ResourceNotFound` - if no database with that name exists

### create(self, name) |
Create a new database with the given name. Parameters: `name` - the name of the database Returns: Database a Database object representing the created database Raises: `PreconditionFailed` - if a database with that name already exists

### delete(self, name) |
Delete the database with the specified name. Parameters: `name` - the name of the database Raises: `ResourceNotFound` - if a database with that name does not exist Since: 0.6

### replicate(self, source, target, **options) |
Replicate changes from the source database to the target database. Parameters: `source` - URL of the source database `target` - URL of the target database `options` - optional replication args, e.g. continuous=True

Property Details

### config The configuration of the CouchDB server. The configuration is represented as a nested dictionary of sections and options from the configuration files of the server, or the default values for options that are not explicitly configured. Get Method: unreachable.config(self) - The configuration of the CouchDB server. Type: `dict`

### version The version string of the CouchDB server. Note that this results in a request being made, and can also be used to check for the availability of the server. Get Method: unreachable.version(self) - The version string of the CouchDB server. Type: `unicode`