Module dbf :: Class DbfTable
[hide private]
[frames] | no frames]

Class DbfTable

source code

object --+
         |
        DbfTable
Known Subclasses:

Provides an interface for working with dBase III tables.
Nested Classes [hide private]
  _memoClass
Provides access to memo files
Instance Methods [hide private]
 
_buildHeaderFields(yo) source code
 
_checkMemoIntegrity(yo)
dBase III specific
source code
 
_initializeFields(yo)
builds the FieldList of names, types, and descriptions
source code
 
_fieldLayout(yo, i)
Returns field information Name Type(Length[,Decimals])
source code
 
_loadtable(yo) source code
 
_updateDisk(yo, headeronly=False) source code
 
__contains__(yo, key) source code
 
__getattr__(yo, name) source code
 
__getitem__(yo, value) source code
 
__init__(yo, filename, fieldlist='', memosize=128, ignore_memos=False, readonly=False, keep_memos=False, metaonly=False, codepage='cp1252')
open/create dbf file
source code
 
__iter__(yo) source code
 
__len__(yo) source code
 
__repr__(yo)
repr(x)
source code
 
__str__(yo)
str(x)
source code
 
add_fields(yo, fieldspec)
adds field(s) to the table layout; format is Name Type(Length,Decimals)[; Name Type(Length,Decimals)[...]]
source code
 
append(yo, kamikaze='', drop=False, multiple=1)
adds <multiple> blank records, and fills fields with dict/tuple values if present
source code
 
bof(yo)
moves record pointer to previous usable record; returns True if no more usable records
source code
 
bottom(yo, get_record=False)
sets record pointer to bottom of table if get_record, seeks to and returns last (non-deleted) record DbfError if table is empty Bof if all records deleted and use_deleted is False
source code
 
close(yo, keep_table=False, keep_memos=False)
closes disk files ensures table data is available if keep_table ensures memo data is available if keep_memos
source code
 
current(yo, index=False)
returns current logical record, or its index
source code
 
delete_fields(yo, fields)
removes field(s) from the table
source code
 
eof(yo)
moves record pointer to next usable record; returns True if no more usable records
source code
 
export(yo, records=None, filename=None, fieldlist=None, format='csv', header=True)
writes the table using CSV or tab-delimited format, using the filename given if specified, otherwise the table name
source code
 
goto(yo, criteria)
changes the record pointer to the first matching (non-deleted) record criteria should be either a tuple of tuple(value, field, func) triples, or an integer to go to
source code
 
index(yo, sort=None, reverse=False)
orders the table using the sort provided; removes index if no sort provided
source code
 
is_memotype(yo, name)
returns True if name is a memo type field
source code
 
new(yo, filename, _fieldlist='')
returns a new table of the same type
source code
 
next(yo)
set record pointer to next (non-deleted) record, and return it
source code
 
pack(yo, _pack=True)
physically removes all deleted records
source code
 
prev(yo)
set record pointer to previous (non-deleted) record, and return it
source code
 
query(yo, sql=None, python=None) source code
 
rename_field(yo, oldname, newname)
renames an existing field
source code
 
search(yo, match, fuzzy=None, indices=False)
searches using a binary algorythm looking for records that match the criteria in match, which is a tuple with a data item per ordered field.
source code
 
size(yo, field)
returns size of field as (length, decimals)
source code
 
structure(yo, fields=None)
return character list of fields suitable for creating same table layout
source code
 
top(yo, get_record=False)
sets record pointer to top of table; if get_record, seeks to and returns first (non-deleted) record DbfError if table is empty Eof if all records are deleted and use_deleted is False
source code
 
type(yo, field)
returns type of field
source code
 
zap(yo, areyousure=False)
removes all records from table -- this cannot be undone! areyousure must be True, else error is raised
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Class Variables [hide private]
  _version = 'dBase III Plus'
  _versionabbv = 'db3'
  _fieldtypes = {'C': {'Blank': <type 'str'>, 'Init': <function ...
  _memoext = '.dbt'
  _memotypes = ('M')
  _yesMemoMask = '\x80'
  _noMemoMask = '\x7f'
  _fixedFields = ('D', 'L', 'M')
  _decimalFields = ('N')
  _variableFields = ('C')
  _numericFields = ('N')
  _dbfTableHeader = '\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0...
  _dbfTableHeaderExtra = ''
  _supported_tables = ['\x03', '\x83']
  _readonly = False
  _metaonly = False
  use_deleted = True
Properties [hide private]
  field_count
the number of fields in the table
  field_names
a list of the fields in the table
  filename
table's file name
  last_update
  memoname
table's memo name
  record_length
  record_number
number of the current record
  supported_tables
allowable table types
  version
returns the dbf type of the table

Inherited from object: __class__

Method Details [hide private]

__init__(yo, filename, fieldlist='', memosize=128, ignore_memos=False, readonly=False, keep_memos=False, metaonly=False, codepage='cp1252')
(Constructor)

source code 
open/create dbf file
Overrides: object.__init__

__repr__(yo)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(yo)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

search(yo, match, fuzzy=None, indices=False)

source code 
searches using a binary algorythm looking for records that match the criteria in match, which is a tuple with a data item per ordered field. table must be sorted. if index, returns a list of records' indices from the current sort order.

Class Variable Details [hide private]

_fieldtypes

Value:
{'C': {'Blank': <type 'str'>,
       'Init': <function _addCharacter at 0x0100FA70>,
       'Retrieve': <function _retrieveCharacter at 0x0100F570>,
       'Slicable': True,
       'Type': 'Character',
       'Update': <function _updateCharacter at 0x0100F5B0>},
 'D': {'Blank': <bound method type.today of <class 'dbf.Date'>>,
       'Init': <function _addDate at 0x0100FAB0>,
...

_dbfTableHeader

Value:
'\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00'

Property Details [hide private]

field_count

the number of fields in the table
Get Method:
unreachable.field_count(yo) - the number of fields in the table

field_names

a list of the fields in the table
Get Method:
unreachable.field_names(yo) - a list of the fields in the table

filename

table's file name
Get Method:
unreachable.filename(yo) - table's file name

last_update

Get Method:
unreachable.last_update(yo)

memoname

table's memo name
Get Method:
unreachable.memoname(yo) - table's memo name

record_length

Get Method:
unreachable.record_length(yo)

record_number

number of the current record
Get Method:
unreachable.record_number(yo) - number of the current record

supported_tables

allowable table types
Get Method:
unreachable.supported_tables(yo) - allowable table types

version

returns the dbf type of the table
Get Method:
unreachable.version(yo) - returns the dbf type of the table