faucet.nsodbc module

This module exposes an api to deal with db operations on no-sql databases. Currently couchdb support is included.

class faucet.nsodbc.ConnectionCouch(conn, credentials)[source]

Bases: object

Connection class.

This class is specific to couchdb operations. For others a new class will be needed (following same standards)

connected_databases()[source]

Return the connected databases of this connection

create(db_name)[source]

Create a database. If the database exists, return the same and send a True flag. This way, a connection object will only be created once.

delete(db_name)[source]

Delete database specified in the parameter

class faucet.nsodbc.DatabaseCouch(database)[source]

Bases: object

Database specific class exposing the API.

create_view(design, views)[source]

This is a couchdb functionality. Helps in creating views needed for querying the database. Input: Design name, view definition

delete_doc(doc_id)[source]

Delete document based on the doc id

get_docs(view_url, key)[source]

Select docs

A view url is used as select query with the key as a where condition

insert_update_doc(doc, update_key='')[source]

Insert or update a document For updating, a key has to be provided against which a document will be updated

class faucet.nsodbc.NsOdbc[source]

Bases: object

An abstraction layer to make api calls to a non relational database.

Currently the API provided is: connect create get_doc insert_update_doc delete_doc

connect(*conn_string, **kwargs)[source]

Returns a connection object required for further operations Input: connection string or connection parameters Returns: connection object

get_attributes()[source]

Returns API version

faucet.nsodbc.init_flow_db(flow_database)[source]

Initialize/Refresh flow database

Parameters:flow_database
faucet.nsodbc.init_switch_db(switch_database)[source]

Initialize/refresh switch database

Parameters:switch_database
faucet.nsodbc.nsodbc_factory()[source]

factory method to consume the API

faucet.nsodbc.todict(conn_string, kwargs)[source]

Converts the input connection string into a dictionary.

Assumption: Connection string is of the format ‘driver=couchdb;server=localhost;uid=database_uid;pwd=database_pwd’