[python-win32] problems with recordset object
Zev Spitz
shivisi at nana.co.il
Thu Sep 2 21:27:21 CEST 2010
It's the Fields collection (with an uppercase F), not the fields
collection.
Python is case-sensitive.
On 9/2/2010 5:38 PM, python-win32-request at python.org wrote:
> Send python-win32 mailing list submissions to
> python-win32 at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/python-win32
> or, via email, send a message with subject or body 'help' to
> python-win32-request at python.org
>
> You can reach the person managing the list at
> python-win32-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of python-win32 digest..."
>
>
> Today's Topics:
>
> 1. FW: Problems with recordset object (Dardo Schuster Glez)
> 2. Re: FW: Problems with recordset object (David Hutto)
> 3. Re: Installation problem: Python 2.6.6 (32-Bit) on Windows 7
> (32-Bit) (Brian Curtin)
> 4. Re: Installation problem: Python 2.6.6 (32-Bit) on Windows 7
> (32-Bit) (Tony Cappellini)
> 5. Re: Installation problem: Python 2.6.6 (32-Bit) on Windows 7
> (32-Bit) (Brian Curtin)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 2 Sep 2010 10:36:38 +0000
> From: Dardo Schuster Glez<dardoschuster at hotmail.com>
> To:<python-win32 at python.org>
> Subject: [python-win32] FW: Problems with recordset object
> Message-ID:<SNT110-W40EDB32838F92ECFB3C8FFAE8C0 at phx.gbl>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
>
>
>
> Dear Sirs
>
> I was programming many years with delphi/sql server and now i am looking python with your ado library to migrate . I am making my first ado program with python using python 3.1 and pythonwin but i have a problem : recordset can?t acces fields data i send you a sample and the answer from python
>
> # First import two useful modules
> import win32com.client
> from adoconstants import *
> # Create the ADO Connection object via COM.
> oConn = win32com.client.Dispatch('ADODB.Connection')
> # Now set the connection properties via the ConnectionString
> # We're connecting to a SQL Server on 192.168.1.100 using OLEDB.
> oConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\personal.mdb;"
> # Now open the connection
> oConn.Open()
>
> if oConn.State == adStateOpen:
> # Do something here
> print ("We've connected to the database.")
> # Now create a RecordSet object and open a table
> rs = win32com.client.Dispatch('ADODB.Recordset')
> rs.Open("select * from agenda",oConn,1,3) # Open a table called agenda
> # Can also use oRS.Open("zipcode", oConn) instead of setting ActiveConnection
> print( repr(rs))
>
> while not rs.EOF:
> print (rs.fields("nombre"))
> # Move to the next record in the RecordSet
> rs.MoveNext()
>
> # Close up the connection and unload the COM object
> if oConn.State == adStateOpen: oConn.Close()
> oConn = None
>
>
> Answer from python
>
> We've connected to the database.
> <win32com.gen_py.Microsoft ActiveX Data Objects 2.8 Library._Recordset instance at 0x26371984>
> Traceback (most recent call last):
> File "C:\Dardo\Lenguaje Python\ado\Ejemplo\base-de-datos.py", line 27, in<module>
> print (rs.fields("nombre"))
> File "C:\Python31\lib\site-packages\win32com\client\__init__.py", line 462, in __getattr__
> raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
> AttributeError: '<win32com.gen_py.Microsoft ActiveX Data Objects 2.8 Library._Recordset instance at 0x26371984>' object has no attribute 'fields'
>
> Which is the problem ???
> Please answer a soon as posible
> Thanks
> Dardo R. Schuster
> Tenerife - canary islands - Spain
>
>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:<http://mail.python.org/pipermail/python-win32/attachments/20100902/01d46680/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 2 Sep 2010 09:11:05 -0400
> From: David Hutto<smokefloat at gmail.com>
> To: Dardo Schuster Glez<dardoschuster at hotmail.com>
> Cc: python-win32 at python.org
> Subject: Re: [python-win32] FW: Problems with recordset object
> Message-ID:
> <AANLkTindiXC4Xdc7vA8yjwvkTtn5K2SHNpjD_Wsu2rUy at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Thu, Sep 2, 2010 at 6:36 AM, Dardo Schuster Glez
> <dardoschuster at hotmail.com> wrote:
>> Dear Sirs
>>
>> I was programming many years with delphi/sql server and now i am looking
>> python with your ado library to migrate . I am making my first ado program
>> with python using python 3.1 and pythonwin but i have a problem : recordset
>> can?t acces fields data i send you a sample and the answer from python
>>
>> # First import two useful modules
>> import win32com.client
>> from adoconstants import *
>> # Create the ADO Connection object via COM.
>> oConn = win32com.client.Dispatch('ADODB.Connection')
>> # Now set the connection properties via the ConnectionString
>> # We're connecting to a SQL Server on 192.168.1.100 using OLEDB.
>> oConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
>> Source=C:\personal.mdb;"
>> # Now open the connection
>> oConn.Open()
>>
>> if oConn.State == adStateOpen:
>> ? # Do something here
>> ? print ("We've connected to the database.")
>> # Now create a RecordSet object and open a table
>> ? rs = win32com.client.Dispatch('ADODB.Recordset')
>> ? rs.Open("select * from agenda",oConn,1,3)???????????? # Open a table
>> called agenda
>> ? # Can also use oRS.Open("zipcode", oConn) instead of setting
>> ActiveConnection
>> ? print( repr(rs))
>>
>> ? while not rs.EOF:
>> ????? print (rs.fields("nombre"))
>> ????? # Move to the next record in the RecordSet
>> ????? rs.MoveNext()
>>
>> # Close up the connection and unload the COM object
>> ? if oConn.State == adStateOpen: oConn.Close()
>> ? oConn = None
>>
>>
>> Answer from python
>>
>> We've connected to the database.
>> <win32com.gen_py.Microsoft ActiveX Data Objects 2.8 Library._Recordset
>> instance at 0x26371984>
>> Traceback (most recent call last):
>> ? File "C:\Dardo\Lenguaje Python\ado\Ejemplo\base-de-datos.py", line 27, in
>> <module>
>> ??? print (rs.fields("nombre"))
> I'm not positive but I think it's telling you that this rs has no
> attribute fields. So us help(rs) and see if you're using it correctly
> or maby you need to reference a class as well before using it.
>
>> ? File "C:\Python31\lib\site-packages\win32com\client\__init__.py", line
>> 462, in __getattr__
>> ??? raise AttributeError("'%s' object has no attribute '%s'" % (repr(self),
>> attr))
>> AttributeError: '<win32com.gen_py.Microsoft ActiveX Data Objects 2.8
>> Library._Recordset instance at 0x26371984>' object has no attribute 'fields'
>>
>> Which is the problem ???
>> Please answer a soon as posible
>> Thanks
>> Dardo R. Schuster
>> Tenerife - canary islands - Spain
>>
>>
>>
>>
>> _______________________________________________
>> python-win32 mailing list
>> python-win32 at python.org
>> http://mail.python.org/mailman/listinfo/python-win32
>>
>>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 2 Sep 2010 09:11:14 -0500
> From: Brian Curtin<brian.curtin at gmail.com>
> To: cappy2112 at gmail.com
> Cc: python-win32 at python.org
> Subject: Re: [python-win32] Installation problem: Python 2.6.6
> (32-Bit) on Windows 7 (32-Bit)
> Message-ID:
> <AANLkTiksGK8HPtxPZMvUKeXP1b9gRhA2Ut=9ArzWmp1V at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Thu, Sep 2, 2010 at 01:08, Tony Cappellini<cappy2112 at gmail.com> wrote:
>
>> Thanks Brian.
>> If it's a known bug, why don't they pull that installer down?
>
> Then there would be no installers for 2.6.6, effectively removing Windows
> from the list of supported platforms. The compile step is nice, but not
> required, and certainly not a show-stopper.
>
> http://bugs.python.org/issue6716 is one of the few issues on the topic, and
> it contains the fixes by Martin, which were only applied to trunk (2.7) and
> py3k (3.2).
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:<http://mail.python.org/pipermail/python-win32/attachments/20100902/aec527e7/attachment-0001.html>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 2 Sep 2010 07:27:50 -0700
> From: Tony Cappellini<cappy2112 at gmail.com>
> To: Brian Curtin<brian.curtin at gmail.com>
> Cc: python-win32 at python.org
> Subject: Re: [python-win32] Installation problem: Python 2.6.6
> (32-Bit) on Windows 7 (32-Bit)
> Message-ID:
> <AANLkTikCKQ6vH-h144ecYY9qQB8suPDr3=nuGsTizf1S at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
>>> If it's a known bug, why don't they pull that installer down?
>> Then there would be no installers for 2.6.6, effectively removing Windows
>> from the list of supported platforms. The compile step is nice, but not
>> required, and certainly not a show-stopper.
> I guess a more important question is, Once installation completes
> without doing the compile step,
> does the same module have a problem compiling when it is imported as
> part of a normal script execution?
>
>
> ------------------------------
>
> Message: 5
> Date: Thu, 2 Sep 2010 09:38:56 -0500
> From: Brian Curtin<brian.curtin at gmail.com>
> To: cappy2112 at gmail.com
> Cc: python-win32 at python.org
> Subject: Re: [python-win32] Installation problem: Python 2.6.6
> (32-Bit) on Windows 7 (32-Bit)
> Message-ID:
> <AANLkTi==x+u5Mx7xNe0C1pQK3vxcY+Q8825kUD_DjUPL at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Thu, Sep 2, 2010 at 09:27, Tony Cappellini<cappy2112 at gmail.com> wrote:
>
>>>> If it's a known bug, why don't they pull that installer down?
>>> Then there would be no installers for 2.6.6, effectively removing Windows
>>> from the list of supported platforms. The compile step is nice, but not
>>> required, and certainly not a show-stopper.
>> I guess a more important question is, Once installation completes
>> without doing the compile step,
>> does the same module have a problem compiling when it is imported as
>> part of a normal script execution?
>>
> Nope, everything else is fine. The bug in the installer had to do with bad
> command line options to compileall.py which is what goes through and
> executes the pyc compilation on stdlib modules. That script was failing to
> run properly, but compilation itself does work.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:<http://mail.python.org/pipermail/python-win32/attachments/20100902/d527edcb/attachment.html>
>
> ------------------------------
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
> End of python-win32 Digest, Vol 90, Issue 2
> *******************************************
>
More information about the python-win32
mailing list