Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79850 > unrolled thread

[ANN] dbf v0.96 is released

Started byEthan Furman <ethan@stoneleaf.us>
First post2014-10-28 12:53 -0700
Last post2014-10-28 13:51 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  [ANN]  dbf v0.96 is released Ethan Furman <ethan@stoneleaf.us> - 2014-10-28 12:53 -0700
    Re: [ANN]  dbf v0.96 is released Cousin Stanley <cousinstanley@gmail.com> - 2014-10-28 13:34 -0700
      Re: [ANN]  dbf v0.96 is released Ethan Furman <ethan@stoneleaf.us> - 2014-10-28 13:51 -0700

#79850 — [ANN] dbf v0.96 is released

FromEthan Furman <ethan@stoneleaf.us>
Date2014-10-28 12:53 -0700
Subject[ANN] dbf v0.96 is released
Message-ID<mailman.15265.1414526038.18130.python-list@python.org>
and finally supports Python 3!  :)

Versions supported are 2.5 - 2.7, and 3.2+

=========================================

dbf
===

dbf (also known as python dbase) is a module for reading/writing
dBase III, FP, VFP, and Clipper .dbf database files.  It's
an ancient format that still finds lots of use (the most common
I'm aware of is retrieving legacy data so it can be stored in a
newer database system; other uses include GIS, stand-alone programs
such as Family History, Personal Finance, etc.).

Highlights
----------

Table -- represents a single .dbf/.dbt (or .fpt) file combination
and provides access to records; suports the sequence access and 'with'
protocols.  Temporary tables can also live entirely in memory.

Record -- repesents a single record/row in the table, with field access
returning native or custom data types; supports the sequence, mapping,
attribute access (with the field names as the attributes), and 'with'
protocols.  Updates to a record object are reflected on disk either
immediately (using gather() or write()), or at the end of a 'with'
statement.

Index -- nonpersistent index for a table.

Fields::

     dBase III (Null not supported)

         Character --> unicode
         Date      --> datetime.date or None
         Logical   --> bool or None
         Memo      --> unicode or None
         Numeric   --> int/float depending on field definition or None

         Float     --> same as numeric

     Clipper (Null not supported)

         Character --> unicode  (character fields can be up to 65,519)

     Foxpro (Null supported)

         General   --> str/bytes (treated as binary)
         Picture   --> str/bytes (treated as binary)

     Visual Foxpro (Null supported)

         Currency  --> decimal.Decimal
         douBle    --> float
         Integer   --> int
         dateTime  --> datetime.datetime

     If a field is uninitialized (Date, Logical, Numeric, Memo, General,
     Picture) then None is returned for the value.

Custom data types::

     Null     -->  used to support Null values

     Char     -->  unicode type that auto-trims trailing whitespace, and
                   ignores trailing whitespace for comparisons

     Date     -->  date object that allows for no date

     DateTime -->  datetime object that allows for no datetime

     Time     -->  time object that allows for no time

     Logical  -->  adds Unknown state to bool's: instead of True/False/None,
                   values are Truth, Falsth, and Unknown, with appropriate
                   tri-state logic; just as bool(None) is False, bool(Unknown)
                   is also False;  the numerical values of Falsth, Truth, and
                   Unknown is 0, 1, 2

     Quantum  -->  similar to Logical, but implements boolean algebra (I think).
                   Has states of Off, On, and Other.  Other has no boolean nor
                   numerical value, and attempts to use it as such will raise
                   an exception


Whirlwind Tour
--------------

     import datetime
     import dbf

     table = dbf.Table(
             filename='test',
             field_specs='name C(25); age N(3,0); birth D; qualified L',
             on_disk=False,
             )
     table.open()

     for datum in (
             ('Spanky', 7, dbf.Date.fromymd('20010315'), False),
             ('Spunky', 23, dbf.Date(1989, 07, 23), True),
             ('Sparky', 99, dbf.Date(), dbf.Unknown),
             ):
         table.append(datum)

     for record in table:
         print record
         print '--------'
         print record[0:3]
         print record['name':'qualified']
         print [record.name, record.age, record.birth]
         print '--------'

     custom = table.new(
             filename='test_on_disk',
             default_data_types=dict(C=dbf.Char, D=dbf.Date, L=dbf.Logical),
             )

     with custom:    # automatically opened and closed
         for record in table:
             custom.append(record)
         for record in custom:
             dbf.write(record, name=record.name.upper())
             print record
             print '--------'
             print record[0:3]
             print record['name':'qualified']
             print [record.name, record.age, record.birth]
             print '--------'

     table.close()

[toc] | [next] | [standalone]


#79853

FromCousin Stanley <cousinstanley@gmail.com>
Date2014-10-28 13:34 -0700
Message-ID<m2oujv$sqh$1@dont-email.me>
In reply to#79850
> ....
> dbf
> ===
> 
> dbf (also known as python dbase) is a module 
> for reading/writing dBase III, FP, VFP, 
> and Clipper .dbf database files.
> ....

  Available via PyPI at ?

    https://pypi.python.org/pypi/dbf/0.96.001


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

[toc] | [prev] | [next] | [standalone]


#79855

FromEthan Furman <ethan@stoneleaf.us>
Date2014-10-28 13:51 -0700
Message-ID<mailman.15269.1414529467.18130.python-list@python.org>
In reply to#79853
On 10/28/2014 01:34 PM, Cousin Stanley wrote:
>> ....
>> dbf
>> ===
>>
>> dbf (also known as python dbase) is a module
>> for reading/writing dBase III, FP, VFP,
>> and Clipper .dbf database files.
>> ....
>
>    Available via PyPI at ?
>
>      https://pypi.python.org/pypi/dbf/0.96.001

Ah, yes, that's the place!  Although I usually leave off the version so the link is always to the most recent:

https://pypi.python.org/pypi/dbf

--
~Ethan~

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web