CodesJava

Easy learning with example program codes

Python CouchDB Tutorial

Python CouchDB

First, install the below packages, to connect with CouchDB by using the Python.

  • Python interpreter
  • CouchDB database
  • Python-CouchDB driver

 

Follow the below steps to connect with CouchDB by using the Python:

  • Install Python-CouchDB driver.
    # pip install couchdb
    
  • Start MongoDB Service
    # service couchdb start
    
  • Create a Python Script
    # vi PythonCouch.py
    
  • PythonCouch.py:

    import couchdb    
    couch = couchdb.Server()    
    db = couch.create('example')  
    print("Database Successfully Created.");  
    doc = {'name':'Students'}  
    db.save(doc) 
    print("Document Successfully Created.")  
    print("The name of the document is: "+doc['name'])  
    
  • Access CouchDB at the URL: http://localhost:5984/_utils.
  • Thus access the database on localhost.
  • Execute the Python Script PythonCouch.py.
    # python PythonCouch.py
  • Access the created database and check the stored value.

 

Please follow and like us:
error









Copyright © 2019 CodesJava DMCA.com Protection Status