<commit_before>Wallaby backend for CouchDB
===========================

This package provides an asynchronous python interface to CouchDB (using twisted).

Installation
============

You can install the couchdb backend with pip

```bash
pip install wallaby-backend-couchdb
```

How to use
==========

The library is based on twisted's asynchronous pattern. To use the library in an asynchronous fassion you 
first need to create an reactor based application:
 
```python
from twisted.internet import defer

@defer.inlineCallbacks
def run():
    # wait 1 second
    d = defer.Deferred()
    reactor.callLater(1.0, d.callback)
    yield d

    # stop the reactor and quit the application
    reactor.stop()

from twisted.internet import reactor
reactor.callWhenRunning(run)
reactor.run()
```

Now we can connect to an existing CouchDB database:

```python
@defer.inlineCallbacks
def run():
    # Create database client object
    from wallaby.backends.couchdb import Database
    db = Database(
        "<name of database>", 
        username="<username>", 
        password="<password>", 
        url="http://localhost:5984"
    )

    # Query database info in an async manner
    info = yield db.info()

    # Output the info dict
    print info

    # <----- More example Code paste here

    # stop the reactor and quit the application
    reactor.stop()
```

Read and write document
-----------------------

```python
    # Get a document by id
    doc = yield db.get('docid')

    # add a new value to the document
    doc['test'] = 'Hello World'

    # save the document
    res = yield db.save(doc)
```

Creating and deleting documents
-------------------------------<commit_msg>added manual for creating and destroying databases<commit_after>Wallaby backend for CouchDB
===========================

This package provides an asynchronous python interface to CouchDB (using twisted).

Installation
============

You can install the couchdb backend with pip

```bash
pip install wallaby-backend-couchdb
```

How to use
==========

The library is based on twisted's asynchronous pattern. To use the library in an asynchronous fassion you 
first need to create an reactor based application:
 
```python
from twisted.internet import defer

@defer.inlineCallbacks
def run():
    # wait 1 second
    d = defer.Deferred()
    reactor.callLater(1.0, d.callback)
    yield d

    # stop the reactor and quit the application
    reactor.stop()

from twisted.internet import reactor
reactor.callWhenRunning(run)
reactor.run()
```

Now we can connect to an existing CouchDB database:

```python
@defer.inlineCallbacks
def run():
    # Create database client object
    from wallaby.backends.couchdb import Database
    db = Database(
        "<name of database>", 
        username="<username>", 
        password="<password>", 
        url="http://localhost:5984"
    )

    # Query database info in an async manner
    info = yield db.info()

    # Output the info dict
    print info

    # <----- More example Code paste here

    # stop the reactor and quit the application
    reactor.stop()
```

Create and delete database
--------------------------

With the required permissions you could easily create and destroy databases

```python
    newdb = Database(
        "<name of new database>", 
        username="<username>", 
        password="<password>", 
        url="http://localhost:5984"
    )

    # Create the new database 
    res = yield newdb.create()

    # Destroy the new database
    res = yield newdb.destroy()
```

Read and write document
-----------------------

```python
    # Get a document by id
    doc = yield db.get('docid')

    # add a new value to the document
    doc['test'] = 'Hello World'

    # save the document
    res = yield db.save(doc)
```

Creating and deleting documents
-------------------------------
{'fraction_non_alphanumeric': 0.1422996878251821, 'fraction_numerical': 0.004682622268470343, 'mean_word_length': 2.7659157688540645, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7401232', 'n_tokens_mistral': 1094, 'n_tokens_neox': 998, 'n_words': 401}