[DAO Database in win32] What is more efficient
Arturo Pérez Mulas
arturo_perez at wanadoo.es
Wed Dec 6 10:09:22 CET 2000
> If you aren't using ADO you should be. DAO was replaced by ADO some time
> The recordset's EOF property will be true right after the OpenRecordset()
> the recordset is empty.
Thank you! I will check ADO
> I don't know what you mean by "register" in this context. Your examples
> simply checking a table to see if any row has the desired value in a
> If you don't know the database structure you will have trouble writing
> queries; SQL statements can't refer to columns that aren't defined. You'll
> generate an error, not an empty recordset.
Yeah, sorry... by register I meant "row"... I know the database structure,
I did not design it, and cannot change it. With that I meant that I cannot
a column to have "unique" data as you can within Access, so I need to
check for the existence of a value before inserting it.
> The simplest and fastest way to see if any row has a desired value in a
> column is:
> rs = db.OpenRecordset("select count(*) as 'nrows' from table where field
> The resulting recordset will have exactly one row, and one column named
> 'nrows.' The value of that column is how many rows were found where field
> value. If the number is 0 there were no matches.
> Using the database engine to scan the table will be a lot faster than
> looping over a cursor as your second example does.
That is great! Thank you so much!!!! That hits the nail.
More information about the Python-list