<div dir="ltr">Taken from working code... this is probably not the only or best way to handle it; it's just one way to handle it that does work.<br><br> for keyword in keywords:<br> cursors[keyword] = dbhandle.cursor()<br>
if cursors[keyword].set(keyword, DB_SET) == None:<br> del(cursors[keyword])<br> if len(cursors) == 0:<br> return []<br> cursor = dbhandle.join(cursors.values())<br> dbresult = cursor.get(DB_JOIN_ITEM)<br>
while dbresult:<br> results.append(self.get(dbresult[0]))<br> dbresult = cursor.get(DB_JOIN_ITEM)<br><br><div class="gmail_quote">On Tue, Oct 21, 2008 at 12:43 AM, Sury Soni <span dir="ltr"><<a href="mailto:ssoni@nextdigital.com">ssoni@nextdigital.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<p dir="ltr"><span lang="en-au"></span><span lang="en-au"><font color="#000080" face="Arial" size="2">Sorry for not properly expressing my question.</font></span></p>
<p dir="ltr"><span lang="en-au"></span><span lang="en-au"></span></p>
<p dir="ltr"><span lang="en-au"><font color="#000080" face="Arial" size="2">My question</font></span><span lang="en-au"></span><span lang="en-au"> <font color="#000080" face="Arial" size="2">is</font></span><span lang="en-au"></span><span lang="en-au"><font color="#000080" face="Arial" size="2"> how I determine if individual cursor is non-empty</font></span><span lang="en-au"></span><span lang="en-au"><font color="#000080" face="Arial" size="2"> or cursor set to particular record</font></span><span lang="en-au"></span><span lang="en-au"><font color="#000080" face="Arial" size="2">. Once that determined, it can be put on a common list and join() them all together</font></span><span lang="en-au"></span><span lang="en-au"><font color="#000080" face="Arial" size="2">, which is what I am doing in my previous email code.</font></span></p>
<p dir="ltr"><span lang="en-au"><font color="#000080" face="Arial" size="2">So, to determine individual cursor, I tried using count() which was throwing exception</font></span><span lang="en-au"></span><span lang="en-au"><font color="#000080" face="Arial" size="2"> and same with get_current_size(), as</font></span><span lang="en-au"></span><span lang="en-au"> <font color="#000080" face="Arial" size="2">before calling these functions,</font></span><span lang="en-au"></span><span lang="en-au"> <font color="#000080" face="Arial" size="2">I am using pget() for each individual cursor to point to first matching record on BTREE. So if records are not found</font></span><span lang="en-au"></span><span lang="en-au"> <font color="#000080" face="Arial" size="2">for</font></span><span lang="en-au"></span><span lang="en-au"> <font color="#000080" face="Arial" size="2">my pattern key, then pointer on cursor is not set to any record.</font></span><span lang="en-au"><b></b></span><span lang="en-au"><b> <font color="#000080" face="Arial" size="2">How could I determine, if cursor is not yet positioned to some specific record</font></b></span><span lang="en-au"></span><span lang="en-au"><font color="#000080" face="Arial" size="2">, before I can use that cursor to check count() or get_current_size() and later use join().</font></span></p>
<p dir="ltr"><span lang="en-au"></span><span lang="en-au"></span></p>
<p dir="ltr"><span lang="en-au"><font color="#000080" face="Arial" size="2">I hope, I made my question clearer this time?</font></span></p>
<p dir="ltr"><span lang="en-au"><font color="#000080" face="Arial" size="2">Regards,</font></span></p>
<p dir="ltr"><span lang="en-au"><font color="#000080" face="Arial" size="2">Sury</font></span><span lang="en-au"></span><span lang="en-au"></span></p>
<p dir="ltr"><span lang="en-au"></span><span lang="en-au"></span></p>
<p dir="ltr"><span lang="en-au"></span><span lang="en-au"></span></p>
<p dir="ltr"><span lang="en-au"></span><span lang="en-us"></span><span lang="en-au"></span><span lang="en-us"></span></p>
<p dir="ltr"></p><div class="Ih2E3d"><span lang="en-au"></span><span lang="en-au"><b></b></span><span lang="en-au"><b></b></span><b><span lang="en-us"><font face="Tahoma" size="2">From:</font></span></b><span lang="en-au"></span><span lang="en-au"></span><span lang="en-us"><font face="Tahoma" size="2"> <a href="mailto:pybsddb-bounces@argo.es" target="_blank">pybsddb-bounces@argo.es</a> [<a href="mailto:pybsddb-bounces@argo.es" target="_blank">mailto:pybsddb-bounces@argo.es</a>]</font></span><span lang="en-au"><b></b></span><span lang="en-au"><b></b></span><b><span lang="en-us"> <font face="Tahoma" size="2">On Behalf Of</font></span></b><span lang="en-au"></span><span lang="en-au"></span><span lang="en-us"> <font face="Tahoma" size="2">phu<br>
</font></span><span lang="en-au"><b></b></span><span lang="en-au"><b></b></span></div><b><span lang="en-us"><font face="Tahoma" size="2">Sent:</font></span></b><span lang="en-au"></span><span lang="en-au"></span><span lang="en-us"><font face="Tahoma" size="2"> Tuesday, 21 October 2008 4:30 PM<br>
</font></span><div class="Ih2E3d"><span lang="en-au"><b></b></span><span lang="en-au"><b></b></span><b><span lang="en-us"><font face="Tahoma" size="2">To:</font></span></b><span lang="en-au"></span><span lang="en-au"></span><span lang="en-us"><font face="Tahoma" size="2"> Python bindings for Oracle Berkeley DB<br>
</font></span><span lang="en-au"><b></b></span><span lang="en-au"><b></b></span><b><span lang="en-us"><font face="Tahoma" size="2">Subject:</font></span></b><span lang="en-au"></span><span lang="en-au"></span><span lang="en-us"><font face="Tahoma" size="2"> Re: [pybsddb] BDB Indexing and Joined Cursor issue</font></span><span lang="en-au"></span><span lang="en-us"></span></div>
<p dir="ltr"><span lang="en-au"></span></p>
<p dir="ltr"><span lang="en-au">If your question is how to avoid joining empty cursors, just create an empty list and append your non-zero-count cursors to it; if you end up with at least one cursor in your list, you can run your join (joining one cursor should not cause errors, but you can either do that or just use the single cursor, whichever you prefer). If you end up with an empty list, then you know you have no cursors which return values, and should not attempt to either join or get from your cursors. pget will not be an option once you have joined, as joined cursors only support get and close.</span></p>
</div>
<br>_______________________________________________<br>
pybsddb mailing list<br>
<a href="mailto:pybsddb@argo.es">pybsddb@argo.es</a><br>
<a href="http://mailman.argo.es/listinfo/pybsddb" target="_blank">http://mailman.argo.es/listinfo/pybsddb</a><br>
<a href="http://www.argo.es/%7Ejcea/programacion/pybsddb.htm" target="_blank">http://www.argo.es/~jcea/programacion/pybsddb.htm</a><br></blockquote></div><br></div>