<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4134.100" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hello,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I am accessing an Access database under Windows NT
from Python. I am</FONT></DIV>
<DIV><FONT face=Arial size=2>using Mark's python windows extensions to access
through the DAO</FONT></DIV>
<DIV><FONT face=Arial size=2>objects, and I have a question and a performance
comment:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>a) When I open a connection and create a recordset
executing an arbitrary</FONT></DIV>
<DIV><FONT face=Arial size=2>SQL instruction, as follows:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>db = dbengine.OpenDatabase("filename")</FONT></DIV>
<DIV><FONT face=Arial size=2>SQL_query = 'SELECT Table1.Column1, Table2.Colum2
FROM Table1 INNER JOIN Table2 ON (Table1.Num
= Table2.Num) WHERE (((Table1.ID)="name"));'</FONT></DIV>
<DIV><FONT face=Arial size=2>myrecordset =
self.db.OpenRecordset(SQL_BCSet_query)<BR></DIV>
<DIV></FONT><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Is there any way to check if the resulting
recordset is empty?</FONT></DIV>
<DIV><FONT face=Arial size=2> </DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT face=Arial size=2>b) I need to add a register to a database but being
sure that one particular field is not repeated; I have no access to the
predefined structure of the</FONT></DIV>
<DIV><FONT face=Arial size=2>database, so I need to check manually if such a
register exists before adding it; which of the following is more
efficient?:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> - make
an SQL query restricting the table records with "WHERE field = desired_value"
and then check if the resulting recordset is empty</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> -
retrieve the whole table to a recordset, and check the records one by
one:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
myrecordset.MoveFirst()<BR>
while not myrecordset.EOF:</FONT></DIV>
<DIV><FONT face=Arial size=2>
if
myrecordset.Fields(n) == desired_value:</FONT></DIV>
<DIV><FONT face=Arial
size=2>
print "found in db"</FONT></DIV>
<DIV><FONT face=Arial
size=2> break</FONT></DIV>
<DIV><FONT face=Arial size=2>
myrecordset.MoveNext()<BR></DIV></FONT></BODY></HTML>