[python-win32] ADODB.Recordset returning incorrect results

Graeme Glass graemeglass at gmail.com
Thu Jun 21 09:40:33 CEST 2007


On 6/21/07, Matthew Perry <perrygeo at gmail.com> wrote:
>
> Hi all,
>
>   I'm using Access 2000 .mdb as a backend to my python script and am
> seeing some inconsistencies in the results.
>
> If I run the script below, I get 15 rows.
>
> If I run the SAME EXACT query directly in MS Access, I get 12 rows.
>
> Perhaps relevant to the issue - the table referenced in the query
> below is not actually a table but another query. Can you use rs.Open()
> on a chained query? Is there some sort of caching going on? Why is
> there a discrepency?
>
> Thanks for any tips!
>
>
> =========================
> import win32com.client
>
> conn = win32com.client.Dispatch('ADODB.Connection')
> DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:/test1.mdb;'
> conn.Open(DSN)
>
> rs = win32com.client.Dispatch('ADODB.Recordset')
>
> sql = "SELECT [STUDY AREA] AS area FROM [qry base dataset - SS copcs
> only] GROUP BY [STUDY AREA]"
> rs.Open(sql, conn, 1, 3)
>
> numrows = 0
> if rs.RecordCount > 0:
>     rs.MoveFirst()
>     while not rs.EOF:
>         print str(rs.Fields("area"))
>         rs.MoveNext()
>
> rs.Close()
> conn.Close()
> del conn
> =======================
>
>
> --
> Matthew T. Perry
> http://www.perrygeo.net
>
> "You never change things by fighting the existing reality.
> To change something, build a new model that makes
> the existing model obsolete" - R. Buckminster Fuller
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>




If your not forced to use Access, I would suggest looking at sqlite
(built-in in python2.5 onwards), or available as 3rd party module  in
versions  2.4 and below
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20070621/db5982e2/attachment.html 


More information about the Python-win32 mailing list