On 06/19/2012 07:44 AM, John Fabiani wrote:
> On 06/19/2012 06:35 AM, Coop, Michael wrote:
>> We are trying to determine out how many records are in a FoxPro table,
>> preferably, without first performing an execute statement.
>>
>>
>>
>> In FoxPro, it would be something similar to using recount() or alen().
>> We are using Dabo, Python 2.7 and pyodbc.
>>
>>
>>
>> I've tried cursor.rowcount after an execute method and it just returns a
>> -1.  Any suggestions?
>>
>>
>>
>> Current code:
>>
>>           dialog = wx.FileDialog(None, message='Select Table...', \
>>
>>                                  wildcard='Table/DBF|*.dbf', \
>>
>>                                  style=wx.OPEN)
>>
>>           dialog.ShowModal()
>>
>>           currdir = dialog.GetDirectory()
>>
>>           cnxn = pyodbc.connect(DRIVER='{Microsoft FoxPro VFP Driver
>> (*.dbf)}', \
>>
>>                                   SourceType='DBF', \
>>
>>                                   SourceDB=currdir)
>>
>>           dbf = cnxn.cursor()
>>
>>           currdbf =
>> dialog.GetFilename().replace('.dbf','').replace('.DBF','')
>>
>>           columninfo = dbf.columns(table='%s' % (currdbf,)).fetchall()
>>
>>           for row in columninfo:
>>
>>               # print column names in a selected table
>>
>>               print row.column_name
>>
>>
>>
>>
>>
>> Mike Coop
>> Data Analyst III
>>
>> Kemper Preferred
>> 12926 Gran Bay Parkway West, Jacksonville, FL 32258
>> 904.245.5949
>> [email protected]
>> kemper.com
> I don't see a line of Dabo code here?  I'd use "dbfpy" - it's worked for me.
>
> Could you need dbf.rowcount?
>
> Normally, if you are using Dabo, the rowcount will be set after a
> requery() occurs.
>
> We currently don't have direct support for ODBC nor dbf access.  But
> it's not to hard to create.  Review the code for the other database
> engines (i.e. Postgres, MySQL, FireBird, SQLite In dabo\dabo\db for
> windows).  It's very easy to hard code the connection (see getConnection
> method).  After getting the connection you can follow the code for the
> other methods.  Maybe you could convert dbfpy.py to the work with Dabo.
>
> Johnf
>

I had not checked the current status of python and dbf for a year or 
more.  So I decided to check.  I found several updates and other 
packages.  Check out
http://packages.python.org/dbf/

It looks very good!

Johnf
>

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to