<div dir="ltr">or just use couchbeam ...</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 9, 2013 at 10:47 PM, Yves S. Garret <span dir="ltr"><<a href="mailto:yoursurrogategod@gmail.com" target="_blank">yoursurrogategod@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="h5">On Fri, Aug 9, 2013 at 3:36 PM, Yves S. Garret <span dir="ltr"><<a href="mailto:yoursurrogategod@gmail.com" target="_blank">yoursurrogategod@gmail.com</a>></span> wrote:<br>
<div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>On Fri, Aug 9, 2013 at 12:57 PM, Benoit Chesneau <span dir="ltr"><<a href="mailto:bchesneau@gmail.com" target="_blank">bchesneau@gmail.com</a>></span> wrote:<br>

</div><div><div><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">not sure if it can help but you can use <a href="http://github.com/benoitc/couchc" target="_blank">http://github.com/benoitc/couchc</a> which abstract the internal couchdb api .<div>


<br></div><div>- benoitc<div><div><span></span><br><br>On Friday, August 9, 2013, Yves S. Garret  wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I have a small database that's running right now in CouchDB, it's called sample_database.  What I'd</div>



<div>like to do is to read, create, delete, update documents and run some of the views inside from an </div>
<div>Erlang app.  I looked online and found this example:</div><div><a href="http://www.softwarepassion.com/importing-data-to-couchdb-java-ruby-and-erlang-way/" target="_blank">http://www.softwarepassion.com/importing-data-to-couchdb-java-ruby-and-erlang-way/</a><br>




</div><div><br></div><div>From that, I proceeded to make the following little script:</div><div><div>-module(test).</div><div><br></div><div>-import(queue,[in/1,out/1,new/0]).</div><div>-export([start/0]).</div><div>-include("../couch_db.hrl").</div>




<div><br></div><div>-define(ADMIN_USER_CTX, {user_ctx, #user_ctx{roles = [<<"_admin">>]}}).</div><div><br></div><div>start() -></div><div>  io:format("Hello world!~n~n"),</div><div><br>



</div>
<div>  couch_db:open(<<"sample_database">>, [?ADMIN_USER_CTX]).</div></div><div><br></div><div>However, when I run this, I get the following error:</div><div><div>18> test:start().</div><div>Hello world!</div>




<div><br></div><div>** exception error: undefined function couch_db:open/2</div></div><div><br></div><div>It's obvious I'm not including a library of some sort.  I'm curious how I can connect to my little </div>




<div>database in the simplest way possible just to start with.  Has anyone done this before?<br></div></div>
</blockquote></div></div></div>
</blockquote></div><br></div></div></div><div class="gmail_extra">And I've spoken too soon :) .</div><div class="gmail_extra"><br></div><div class="gmail_extra">This is the code that I currently have:</div><div class="gmail_extra">

<div>
<div class="gmail_extra"><br></div><div class="gmail_extra">-module(test).</div><div class="gmail_extra"><br></div><div class="gmail_extra">-import(queue,[in/1,out/1,new/0]).</div><div class="gmail_extra">-export([start/0]).</div>


</div><div class="gmail_extra">%         /opt/local/lib/couchdb/erlang/lib/couch-1.3.1/ebin</div><div class="gmail_extra">-include("/opt/local/lib/couchdb/erlang/lib/couch-1.3.1/include/couch_db.hrl").</div><div class="gmail_extra">


<br></div><div class="gmail_extra">-define(ADMIN_USER_CTX, {user_ctx, #user_ctx{roles = [<<"some_user">>]}}).</div><div><div class="gmail_extra"><br></div><div class="gmail_extra">start() -></div>

<div class="gmail_extra">
  io:format("Hello world!~n~n"),</div><div class="gmail_extra"><br></div><div class="gmail_extra">  couch_db:open(<<"sample_database">>, [?ADMIN_USER_CTX]).</div><div class="gmail_extra"><br>


</div></div><div class="gmail_extra">It compiles just fine, but when I run it, this is the error that I get:</div><div class="gmail_extra"><div class="gmail_extra">> c(test).     </div><div class="gmail_extra">{ok,test}</div>


<div class="gmail_extra">> test:start().</div><div class="gmail_extra">Hello world!</div><div class="gmail_extra"><br></div><div class="gmail_extra">** exception error: bad argument</div><div class="gmail_extra">     in function  ets:lookup/2</div>


<div class="gmail_extra">        called as ets:lookup(couch_config,{"replicator","db"})</div><div class="gmail_extra">     in call from couch_config:get/3 (couch_config.erl, line 62)</div><div class="gmail_extra">


     in call from couch_server:maybe_add_sys_db_callbacks/2 (couch_server.erl, line 89)</div><div class="gmail_extra">     in call from couch_server:open/2 (couch_server.erl, line 64)</div><div class="gmail_extra">     in call from couch_db:open/2 (couch_db.erl, line 79)</div>


<div class="gmail_extra"><br></div><div class="gmail_extra">I'll be digging into why this is happening.</div></div></div></div>
</blockquote></div><br></div></div></div><div class="gmail_extra">As a work around, I'm thinking of using os:cmd("curl -i -X GET ..."), but that seems like it could</div><div class="gmail_extra">be done better.</div>
</div>
</blockquote></div><br></div>