Tuesday, August 16, 2011

Creating Database In CouchDB using LoveSeat (C#)

Getting Started with CouchDB using Loveseat C#
We all know that there is very limited resources to help Implementing CouchDB using c#. as far as i feel Love Seat is the best.

Here are i am going to discuss very basic thing.
How to create Database in CouchDB using Loveseat c#.net

First step:
we have to create a connection to Couchdb database.

CouchClient ccAdmin = new CouchClient("localhost", 5984, null, null);

In the above code i am passing username and password as null. if you have installed couch db recently then every user will be considered as admin user as long as you have created a new user.

If you have username and password with you the pass them while creating couch client instance.

Here in the following code i am checking for the database existence before creating it.
Note: CouchDB is case sensitive we should not user UpperCase (Capital Letters) while creating database. ("Database1" is wrong syntax! it has to be "database1")

string dbname = "database1";
if (!ccAdmin.HasDatabase(dbname))
{
ccAdmin.CreateDatabase(dbname);
}



No comments:

Post a Comment