CouchDB 1.x API¶
Server¶
- class aiocouchdb.v1.server.Server(url_or_resource='http://localhost:5984', *, authdb_class=None, authdb_name=None, config_class=None, database_class=None, session_class=None)[source]¶
Implementation of CouchDB Server API.
- active_tasks(*, auth=None)[source]¶
Returns list of active tasks which runs on server.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: list
- all_dbs(*, auth=None)[source]¶
Returns list of available databases on server.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: list
- authdb_class¶
Authentication database class
alias of AuthDatabase
- authdb_name = '_users'¶
Authentication database name
- config_class¶
Default ServerConfig instance class
alias of ServerConfig
- db(dbname, *, auth=None)[source]¶
Returns Database instance against specified database name.
If database isn’t accessible for provided auth credentials, this method raises aiocouchdb.errors.HttpErrorException with the related response status code.
Parameters: - dbname (str) – Database name
- auth – aiocouchdb.authn.AuthProvider instance
Return type:
- db_updates(*, auth=None, feed_buffer_size=None, feed=None, timeout=None, heartbeat=None)[source]¶
Emits databases events for the related server instance.
Parameters: Depending on feed type returns:
- dict - for default or longpoll feed
- aiocouchdb.feeds.JsonFeed - for continuous feed
- aiocouchdb.feeds.EventSourceFeed - for eventsource feed
- info(*, auth=None)[source]¶
Returns server meta information and welcome message.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: dict
- log(*, bytes=None, offset=None, auth=None)[source]¶
Returns a chunk of data from the tail of CouchDB’s log file.
Parameters: Return type: str
- replicate(source, target, *, auth=None, authobj=None, cancel=None, continuous=None, create_target=None, doc_ids=None, filter=None, headers=None, proxy=None, query_params=None, since_seq=None, checkpoint_interval=None, connection_timeout=None, http_connections=None, retries_per_request=None, socket_options=None, use_checkpoints=None, worker_batch_size=None, worker_processes=None)[source]¶
Runs a replication from source to target.
Parameters: - source (str) – Source database name or URL
- target (str) – Target database name or URL
- auth – aiocouchdb.authn.AuthProvider instance (don’t confuse with authobj which belongs to replication options)
- authobj (dict) – Authentication object for the target database
- cancel (bool) – Cancels active replication
- continuous (bool) – Runs continuous replication
- create_target (bool) – Creates target database if it not exists
- doc_ids (list) – List of specific document ids to replicate
- filter (str) – Filter function name
- headers (dict) – Custom replication request headers
- proxy (str) – Proxy server URL
- query_params (dict) – Custom query parameters for filter function
- since_seq – Start replication from specified sequence number
- checkpoint_interval (int) – Tweaks checkpoint_interval option
- connection_timeout (int) – Tweaks connection_timeout option
- http_connections (int) – Tweaks http_connections option
- retries_per_request (int) – Tweaks retries_per_request option
- socket_options (str) – Tweaks socket_options option
- use_checkpoints (bool) – Tweaks use_checkpoints option
- worker_batch_size (int) – Tweaks worker_batch_size option
- worker_processes (int) – Tweaks worker_processes option
Return type: dict
- restart(*, auth=None)[source]¶
Restarts server instance.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: dict
- session[source]¶
Proxy to the related session_class instance.
- stats(metric=None, *, auth=None, flush=None, range=None)[source]¶
Returns server statistics.
Parameters: - metric (str) – Metrics name in format group/name. For instance, httpd/requests. If omitted, all metrics will be returned
- flush (bool) – If True, collects samples right for this request
- range (int) – Sampling range
- auth – aiocouchdb.authn.AuthProvider instance
Return type: dict
Configuration¶
- class aiocouchdb.v1.config.ServerConfig(resource)[source]¶
Implements /_config/* API. Should be used via server.config property.
- delete(section, key, *, auth=None)[source]¶
Deletes specific configuration option and returns it value back.
Parameters: Return type: str
- exists(section, key, *, auth=None)[source]¶
Checks if configuration option exists.
Parameters: Return type: bool
- get(section=None, key=None, *, auth=None)[source]¶
Returns server configuration. Depending on specified arguments returns:
- Complete configuration if section and key are None
- Section options if section was specified
- Option value if both section and key were specified
Parameters: Return type: dict or str
Session¶
- class aiocouchdb.v1.session.Session(resource)[source]¶
Implements /_session API. Should be used via server.session property.
- close(*, auth=None)[source]¶
Closes active cookie session. Uses for aiocouchdb.authn.CookieAuthProvider.
alias of CookieAuthProvider
- info(*, auth=None)[source]¶
Returns information about authenticated user. Usable for any AuthProvider.
Return type: dict
Database¶
- class aiocouchdb.v1.database.Database(url_or_resource, *, dbname=None, document_class=None, design_document_class=None, security_class=None, view_class=None)[source]¶
Implementation of CouchDB Database API.
- all_docs(*keys, auth=None, feed_buffer_size=None, att_encoding_info=None, attachments=None, conflicts=None, descending=None, endkey=Ellipsis, endkey_docid=None, include_docs=None, inclusive_end=None, limit=None, skip=None, stale=None, startkey=Ellipsis, startkey_docid=None, update_seq=None)[source]¶
Iterates over all documents view.
Parameters: - keys (str) – List of document ids to fetch. This method is smart enough to use GET or POST request depending on amount of keys
- auth – aiocouchdb.authn.AuthProvider instance
- feed_buffer_size (int) – Internal buffer size for fetched feed items
- att_encoding_info (bool) – Includes encoding information in an attachment stubs
- attachments (bool) – Includes attachments content into documents. Warning: use with caution!
- conflicts (bool) – Includes conflicts information into documents
- descending (bool) – Return rows in descending by key order
- endkey (str) – Stop fetching rows when the specified key is reached
- endkey_docid (str) – Stop fetching rows when the specified document ID is reached
- include_docs (str) – Include document body for each row
- inclusive_end (bool) – When False, doesn’t includes endkey in returned rows
- limit (int) – Limits the number of the returned rows by the specified number
- skip (int) – Skips specified number of rows before starting to return the actual result
- stale (str) – Allow to fetch the rows from a stale view, without triggering index update. Supported values: ok and update_after
- startkey (str) – Return rows starting with the specified key
- startkey_docid (str) – Return rows starting with the specified document ID
- update_seq (bool) – Include an update_seq value into view results header
Return type:
- bulk_docs(docs, *, auth=None, all_or_nothing=None, new_edits=None)[source]¶
Updates multiple documents using a single request.
Parameters: - docs (Iterable) – Sequence of document objects (dict)
- auth – aiocouchdb.authn.AuthProvider instance
- all_or_nothing (bool) – Sets the database commit mode to use all-or-nothing semantics
- new_edits (bool) – If False, prevents the database from assigning them new revision for updated documents
Return type: list
- changes(*doc_ids, auth=None, feed_buffer_size=None, att_encoding_info=None, attachments=None, conflicts=None, descending=None, feed=None, filter=None, headers=None, heartbeat=None, include_docs=None, limit=None, params=None, since=None, style=None, timeout=None, view=None)[source]¶
Emits database changes events.
Parameters: - doc_ids (str) – Document IDs to filter for. This method is smart enough to use GET or POST request depending if any doc_ids were provided or not and automatically sets filter param to _doc_ids value.
- auth – aiocouchdb.authn.AuthProvider instance
- feed_buffer_size (int) – Internal buffer size for fetched feed items
- att_encoding_info (bool) – Includes encoding information in an attachment stubs
- attachments (bool) – Includes the Base64-encoded content of an attachments in the documents
- conflicts (bool) – Includes conflicts information in the documents
- descending (bool) – Return changes in descending order
- feed (str) – Changes feed type
- filter (str) – Filter function name
- headers (dict) – Custom request headers
- heartbeat (int) – Period in milliseconds after which an empty line will be sent from server as the result to keep connection alive
- include_docs (bool) – Includes the associated document for each emitted event
- limit (int) – Limits a number of returned events by the specified value
- since – Starts listening changes feed since given update sequence value
- params (dict) – Custom request query parameters
- style (str) – Changes feed output style: all_docs, main_only
- timeout (int) – Period in milliseconds to await for new changes before close the feed. Works for continuous feeds
- view (str) – View function name which would be used as filter. Implicitly sets filter param to _view value
Return type:
- compact(ddoc_name=None, *, auth=None)[source]¶
Initiates database or view index compaction.
Parameters: - ddoc_name (str) – Design document name. If specified initiates view index compaction instead of database
- auth – aiocouchdb.authn.AuthProvider instance
Return type: dict
- create(*, auth=None)[source]¶
-
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: dict
- ddoc(docid, *, auth=None)[source]¶
Returns DesignDocument instance against specified document ID. This ID may startswith with _design/ prefix and if it’s not prefix will be added automatically.
If document isn’t accessible for auth provided credentials, this method raises aiocouchdb.errors.HttpErrorException with the related response status code.
Parameters: - docid (str) – Document ID
- auth – aiocouchdb.authn.AuthProvider instance
Return type:
- delete(*, auth=None)[source]¶
-
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: dict
- design_document_class¶
alias of DesignDocument
- doc(docid=None, *, auth=None, idfun=<function uuid4 at 0x7fd64a558620>)[source]¶
Returns Document instance against specified document ID.
If document ID wasn’t specified, the idfun function will be used to generate it.
If document isn’t accessible for auth provided credentials, this method raises aiocouchdb.errors.HttpErrorException with the related response status code.
Parameters: - docid (str) – Document ID
- auth – aiocouchdb.authn.AuthProvider instance
- idfun – Document ID generation function. Should return str or other object which could be translated into string
Return type:
- document_class¶
alias of Document
- ensure_full_commit(*, auth=None)[source]¶
Ensures that all bits are committed on disk.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: dict
- exists(*, auth=None)[source]¶
Checks if database exists on server. Assumes success on receiving response with 200 OK status.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: bool
- info(*, auth=None)[source]¶
Returns database information.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: dict
- missing_revs(id_revs, *, auth=None)[source]¶
Returns document missed revisions in the database by given document-revisions mapping.
Parameters: - id_revs (dict) – Mapping between document ID and list of his revisions to search for.
- auth – aiocouchdb.authn.AuthProvider instance
Return type: dict
- purge(id_revs, *, auth=None)[source]¶
Permanently removes specified document revisions from the database.
Parameters: - id_revs (dict) – Mapping between document ID and list of his revisions to purge
- auth – aiocouchdb.authn.AuthProvider instance
Return type: dict
- revs_diff(id_revs, *, auth=None)[source]¶
Returns document revisions difference in the database by given document-revisions mapping.
Parameters: - id_revs (dict) – Mapping between document ID and list of his revisions to compare
- auth – aiocouchdb.authn.AuthProvider instance
Return type: dict
- revs_limit(count=None, *, auth=None)[source]¶
Returns the limit of database revisions to store or updates it if count parameter was specified.
Parameters: - count (int) – Amount of revisions to store
- auth – aiocouchdb.authn.AuthProvider instance
Return type: int or dict
- security[source]¶
Proxy to the related security_class instance.
- security_class¶
alias of DatabaseSecurity
- temp_view(map_fun, red_fun=None, language=None, *, auth=None, feed_buffer_size=None, att_encoding_info=None, attachments=None, conflicts=None, descending=None, endkey=Ellipsis, endkey_docid=None, group=None, group_level=None, include_docs=None, inclusive_end=None, keys=Ellipsis, limit=None, reduce=None, skip=None, stale=None, startkey=Ellipsis, startkey_docid=None, update_seq=None)[source]¶
Executes temporary view and returns it results according specified parameters.
Parameters: - map_fun (str) – Map function source code
- red_fun (str) – Reduce function source code
- language (str) – Query server language to process the view
- auth – aiocouchdb.authn.AuthProvider instance
- feed_buffer_size (int) – Internal buffer size for fetched feed items
- att_encoding_info (bool) – Includes encoding information in an attachment stubs
- attachments (bool) – Includes attachments content into documents. Warning: use with caution!
- conflicts (bool) – Includes conflicts information into documents
- descending (bool) – Return rows in descending by key order
- endkey – Stop fetching rows when the specified key is reached
- endkey_docid (str) – Stop fetching rows when the specified document ID is reached
- group (bool) – Reduces the view result grouping by unique keys
- group_level (int) – Reduces the view result grouping the keys with defined level
- include_docs (str) – Include document body for each row
- inclusive_end (bool) – When False, doesn’t includes endkey in returned rows
- keys (list) – List of view keys to fetch
- limit (int) – Limits the number of the returned rows by the specified number
- reduce (bool) – Defines is the reduce function needs to be applied or not
- skip (int) – Skips specified number of rows before starting to return the actual result
- stale (str) – Allow to fetch the rows from a stale view, without triggering index update. Supported values: ok and update_after
- startkey – Return rows starting with the specified key
- startkey_docid (str) – Return rows starting with the specified document ID
- update_seq (bool) – Include an update_seq value into view results header
Return type:
- view_class¶
alias of View
- view_cleanup(*, auth=None)[source]¶
Removes outdated views index files.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: dict
- class aiocouchdb.v1.authdb.AuthDatabase(url_or_resource, *, dbname=None, document_class=None, design_document_class=None, security_class=None, view_class=None)[source]¶
Represents system authentication database. Used via aiocouchdb.v1.server.Server.authdb.
- document_class¶
alias of UserDocument
Security¶
- class aiocouchdb.v1.security.DatabaseSecurity(resource)[source]¶
Provides set of methods to work with database security API. Should be used via database.security property.
- get(*, auth=None)[source]¶
Returns database security object.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: dict
- update(*, auth=None, admins=None, members=None, merge=False)[source]¶
Updates database security object.
Parameters: Return type: dict
- update_admins(*, auth=None, names=None, roles=None, merge=False)[source]¶
Helper for update() method to update only database administrators leaving members as is.
Parameters: Return type: dict
Document¶
- class aiocouchdb.v1.document.Document(url_or_resource, *, docid=None, attachment_class=None)[source]¶
Implementation of CouchDB Document API.
- att(attname, *, auth=None)[source]¶
Returns Attachment instance against specified attachment.
If attachment isn’t accessible for auth provided credentials, this method raises aiocouchdb.errors.HttpErrorException with the related response status code.
Parameters: - attname (str) – Attachment name
- auth – aiocouchdb.authn.AuthProvider instance
Return type:
- attachment_class¶
alias of Attachment
- copy(newid, rev=None, *, auth=None)[source]¶
Copies a document with the new ID within the same database.
Parameters: Return type: dict
- delete(rev, *, auth=None, preserve_content=None)[source]¶
Deletes a document from server.
By default document will be deleted using DELETE HTTP method. On this request CouchDB removes all document fields, leaving only system _id and _rev and adding "_deleted": true one. When preserve_content set to True, document will be marked as deleted (by adding "_deleted": true field without removing existed ones) via PUT request. This feature costs two requests to fetch and update the document and also such documents consumes more space by oblivious reasons.
Parameters: Return type: dict
- exists(rev=None, *, auth=None)[source]¶
Checks if document exists in the database. Assumes success on receiving response with 200 OK status.
Parameters: - rev (str) – Document revision
- auth – aiocouchdb.authn.AuthProvider instance
Return type: bool
- get(rev=None, *, auth=None, att_encoding_info=None, attachments=None, atts_since=None, conflicts=None, deleted_conflicts=None, local_seq=None, meta=None, open_revs=None, revs=None, revs_info=None)[source]¶
Returns a document object.
Parameters: - rev (str) – Document revision
- auth – aiocouchdb.authn.AuthProvider instance
- att_encoding_info (bool) – Includes encoding information in an attachment stubs
- attachments (bool) – Includes the Base64-encoded content of an attachments in the documents
- atts_since (list) – Includes attachments that was added since the specified revisions
- conflicts (bool) – Includes conflicts information in the documents
- deleted_conflicts (bool) – Includes information about deleted conflicted revisions in the document
- local_seq (bool) – Includes local sequence number in the document
- meta (bool) – Includes meta information in the document
- open_revs (list) – Returns the specified leaf revisions
- revs (bool) – Includes information about all known revisions
- revs_info (bool) – Includes information about all known revisions and their status
Return type: dict or list if open_revs specified
- get_open_revs(*open_revs, auth=None, att_encoding_info=None, atts_since=None, local_seq=None, revs=None)[source]¶
Returns document open revisions with their attachments.
Unlike get(open_revs=[...]), this method works with multipart/mixed response returning multipart reader which is more optimized to handle large data sets with lesser memory footprint.
Note, that this method always returns attachments along with leaf revisions.
Parameters: - open_revs (list) – Leaf revisions to return. If omitted, all leaf revisions will be returned
- auth – aiocouchdb.authn.AuthProvider instance
- att_encoding_info (bool) – Includes encoding information in an attachments stubs
- atts_since (list) – Includes attachments that was added since the specified revisions
- local_seq (bool) – Includes local sequence number in each document
- revs (bool) – Includes information about all known revisions in each document
Return type:
- get_with_atts(rev=None, *, auth=None, att_encoding_info=None, atts_since=None, conflicts=None, deleted_conflicts=None, local_seq=None, meta=None, revs=None, revs_info=None)[source]¶
Returns document with attachments.
This method is more optimal than get(attachments=true) since it uses multipart API and doesn’t requires to read all the attachments, extract then from JSON document and decode from base64.
Parameters: - rev (str) – Document revision
- auth – aiocouchdb.authn.AuthProvider instance
- att_encoding_info (bool) – Includes encoding information in an attachment stubs
- atts_since (list) – Includes attachments that was added since the specified revisions
- conflicts (bool) – Includes conflicts information in the documents
- deleted_conflicts (bool) – Includes information about deleted conflicted revisions in the document
- local_seq (bool) – Includes local sequence number in the document
- meta (bool) – Includes meta information in the document
- revs (bool) – Includes information about all known revisions
- revs_info (bool) – Includes information about all known revisions and their status
Return type:
- modified(rev, *, auth=None)[source]¶
Checks if document was modified in database since specified revision.
Parameters: - rev (str) – Document revision
- auth – aiocouchdb.authn.AuthProvider instance
Return type: bool
- rev(*, auth=None)[source]¶
Returns current document revision by using HEAD request.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: str
- update(doc, *, atts=None, auth=None, batch=None, new_edits=None, rev=None)[source]¶
Updates a document on server.
Parameters: - doc (dict) – Document object. Should implement MutableMapping interface
- auth – aiocouchdb.authn.AuthProvider instance
- atts (dict) – Attachments mapping where keys are represents attachment name and value is file-like object or bytes
- batch (str) – Updates in batch mode (asynchronously) This argument accepts only "ok" value.
- new_edits (bool) – Signs about new document edition. When False allows to create conflicts manually
- rev (str) – Document revision. Optional, since document _rev field is also respected
Return type: dict
Warning
Updating document with attachments is not able to use all the advantages of multipart request due to COUCHDB-2295 issue, so don’t even try to update a document with several gigabytes attachments with this method. Put them one-by-one via aiocouchdb.v1.attachment.Attachment.update() method.
- class aiocouchdb.v1.authdb.UserDocument(*args, **kwargs)[source]¶
Represents user document for the authentication database.
- register(password, *, auth=None, **additional_data)[source]¶
Helper method over aiocouchdb.v1.document.Document.update() to change a user password.
Parameters: - password (str) – User’s password
- auth – aiocouchdb.authn.AuthProvider instance
Return type: dict
- update_password(password, *, auth=None)[source]¶
Helper method over aiocouchdb.v1.document.Document.update() to change a user password.
Parameters: - password (str) – New password
- auth – aiocouchdb.authn.AuthProvider instance
Return type: dict
- class aiocouchdb.v1.document.DocAttachmentsMultipartReader(headers, content)[source]¶
Special multipart reader optimized for requesting single document with attachments. Matches output with OpenRevsMultipartReader.
Design Document¶
- class aiocouchdb.v1.designdoc.DesignDocument(url_or_resource, *, docid=None, document_class=None, view_class=None)[source]¶
Implementation of CouchDB Design Document API.
- doc[source]¶
Returns document_class instance to operate with design document as with regular CouchDB document.
Return type: Document
- document_class¶
alias of Document
- info(*, auth=None)[source]¶
Returns view index information.
Parameters: auth – aiocouchdb.authn.AuthProvider instance Return type: dict
- list(list_name, view_name=None, *keys, auth=None, headers=None, data=None, params=None, format=None, att_encoding_info=None, attachments=None, conflicts=None, descending=None, endkey=Ellipsis, endkey_docid=None, group=None, group_level=None, include_docs=None, inclusive_end=None, limit=None, reduce=None, skip=None, stale=None, startkey=Ellipsis, startkey_docid=None, update_seq=None)[source]¶
Calls a list function and returns a raw response object.
Parameters: For other parameters see aiocouchdb.v1.designdoc.DesignDocument.view() method docstring.
Return type: HttpResponse
- rewrite(*path, auth=None, method=None, headers=None, data=None, params=None)[source]¶
Requests rewrite resource and returns a raw response object.
Parameters: Return type:
- show(show_name, docid=None, *, auth=None, method=None, headers=None, data=None, params=None, format=None)[source]¶
Calls a show function and returns a raw response object.
Parameters: - show_name (str) – Show function name
- docid (str) – Document ID
- auth – aiocouchdb.authn.AuthProvider instance
- method (str) – HTTP request method
- headers (dict) – Additional request headers
- data – Request payload
- params (dict) – Additional request query parameters
- format (str) – Show function output format
Return type:
- update(update_name, docid=None, *, auth=None, method=None, headers=None, data=None, params=None)[source]¶
Calls a show function and returns a raw response object.
Parameters: Return type:
- view(view_name, *keys, auth=None, feed_buffer_size=None, att_encoding_info=None, attachments=None, conflicts=None, descending=None, endkey=Ellipsis, endkey_docid=None, group=None, group_level=None, include_docs=None, inclusive_end=None, limit=None, reduce=None, skip=None, stale=None, startkey=Ellipsis, startkey_docid=None, update_seq=None)[source]¶
Queries a stored view by the name with the specified parameters.
Parameters: - view_name (str) – Name of view stored in the related design document
- keys (str) – List of view index keys to fetch. This method is smart enough to use GET or POST request depending on amount of keys
- auth – aiocouchdb.authn.AuthProvider instance
- feed_buffer_size (int) – Internal buffer size for fetched feed items
- att_encoding_info (bool) – Includes encoding information in an attachment stubs
- attachments (bool) – Includes attachments content into documents. Warning: use with caution!
- conflicts (bool) – Includes conflicts information into documents
- descending (bool) – Return rows in descending by key order
- endkey – Stop fetching rows when the specified key is reached
- endkey_docid (str) – Stop fetching rows when the specified document ID is reached
- group (bool) – Reduces the view result grouping by unique keys
- group_level (int) – Reduces the view result grouping the keys with defined level
- include_docs (str) – Include document body for each row
- inclusive_end (bool) – When False, doesn’t includes endkey in returned rows
- limit (int) – Limits the number of the returned rows by the specified number
- reduce (bool) – Defines is the reduce function needs to be applied or not
- skip (int) – Skips specified number of rows before starting to return the actual result
- stale (str) – Allow to fetch the rows from a stale view, without triggering index update. Supported values: ok and update_after
- startkey – Return rows starting with the specified key
- startkey_docid (str) – Return rows starting with the specified document ID
- update_seq (bool) – Include an update_seq value into view results header
Return type:
- view_class¶
alias of View
Attachment¶
- class aiocouchdb.v1.attachment.Attachment(url_or_resource, *, name=None)[source]¶
Implementation of CouchDB Attachment API.
- accepts_range(rev=None, *, auth=None)[source]¶
Returns True if attachments accepts bytes range requests.
Parameters: - rev (str) – Document revision
- auth – aiocouchdb.authn.AuthProvider instance
Return type: bool
- delete(rev, *, auth=None)[source]¶
-
Parameters: - rev (str) – Document revision
- auth – aiocouchdb.authn.AuthProvider instance
Return type: dict
- exists(rev=None, *, auth=None)[source]¶
Checks if attachment exists. Assumes success on receiving response with 200 OK status.
Parameters: - rev (str) – Document revision
- auth – aiocouchdb.authn.AuthProvider instance
Return type: bool
- get(rev=None, *, auth=None, range=None)[source]¶
Returns an attachment reader object.
Parameters: Return type: AttachmentReader
- modified(digest, *, auth=None)[source]¶
Checks if attachment was modified by known MD5 digest.
Parameters: - digest (bytes) – Attachment MD5 digest. Optionally, may be passed in base64 encoding form
- auth – aiocouchdb.authn.AuthProvider instance
Return type: bool
- update(fileobj, *, auth=None, content_encoding=None, content_type='application/octet-stream', rev=None)[source]¶
Attaches a file to document.
Parameters: Return type: dict
- class aiocouchdb.v1.attachment.AttachmentReader(resp)[source]¶
Attachment reader implements io.RawIOBase interface with the exception that all I/O bound methods are coroutines.
- close()[source]¶
Closes attachment reader and underlying connection.
This method has no effect if the attachment is already closed.
- read(size=-1)[source]¶
Read and return up to n bytes, where size is an int().
Returns an empty bytes object on EOF, or None if the object is set not to block and has no data to read.
- readline()[source]¶
Read and return a line of bytes from the stream.
If limit is specified, at most limit bytes will be read. Limit should be an int().
The line terminator is always b'\n' for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.