Package dbf :: Module tables :: Class DbfTable
[hide private]

Class DbfTable

source code

object --+
         |
        DbfTable
Known Subclasses:

Provides a framework for dbf style tables.

Nested Classes [hide private]
  _memoClass
Provides access to memo fields as dictionaries must override _init, _get_memo, and _put_memo to store memo contents to disk
  _DbfLists
implements the weakref structure for DbfLists
  _Indexen
implements the weakref structure for seperate indexes
  _MetaData
  _TableHeader
  _Table
implements the weakref table for records
  DbfIterator
returns records using current index
Instance Methods [hide private]
 
_buildHeaderFields(yo)
constructs fieldblock for disk table
source code
 
_checkMemoIntegrity(yo)
dBase III specific
source code
 
_initializeFields(yo)
builds the FieldList of names, types, and descriptions from the disk file
source code
 
_fieldLayout(yo, i)
Returns field information Name Type(Length[,Decimals])
source code
 
_loadtable(yo)
loads the records from disk to memory
source code
 
_list_fields(yo, specs, sep=',') source code
 
_update_disk(yo, headeronly=False)
synchronizes the disk file with current data
source code
 
__contains__(yo, key) source code
 
__enter__(yo) source code
 
__exit__(yo, *exc_info) source code
 
__getattr__(yo, name) source code
 
__getitem__(yo, value) source code
 
__init__(yo, filename=':memory:', field_specs=None, memo_size=128, ignore_memos=False, read_only=False, keep_memos=False, meta_only=False, codepage=None, numbers='default', strings=<type 'str'>, currency=<class 'decimal.Decimal'>)
open/create dbf file filename should include path if needed field_specs can be either a ;-delimited string or a list of strings memo_size is always 512 for db3 memos ignore_memos is useful if the memo file is missing or corrupt read_only will load records into memory, then close the disk file keep_memos will also load any memo fields into memory meta_only will ignore all records, keeping only basic table information codepage will override whatever is set in the table itself
source code
 
__iter__(yo) source code
 
__len__(yo) source code
 
__nonzero__(yo) source code
 
__repr__(yo)
repr(x)
source code
 
__str__(yo)
str(x)
source code
 
add_fields(yo, field_specs)
adds field(s) to the table layout; format is Name Type(Length,Decimals)[; Name Type(Length,Decimals)[...]] backup table is created with _backup appended to name then modifies current structure
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, _move=False)
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
 
create_backup(yo, new_name=None, overwrite=False)
creates a backup table -- ignored if memory table
source code
 
create_index(yo, key) source code
 
current(yo, index=False)
returns current logical record, or its index
source code
 
delete_fields(yo, doomed)
removes field(s) from the table creates backup files with _backup appended to the file name, then modifies current structure
source code
 
eof(yo, _move=False)
moves record pointer to next usable record; returns True if no more usable records
source code
 
export(yo, records=None, filename=None, field_specs=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
 
find(yo, command)
uses exec to perform queries on the table
source code
 
get_record(yo, recno)
returns record at physical_index[recno]
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
 
is_decimal(yo, name)
returns True if name is a variable-length field type
source code
 
is_memotype(yo, name)
returns True if name is a memo type field
source code
 
new(yo, filename, field_specs=None, codepage=None)
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
 
open(yo) 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_command=None, python=None)
deprecated: use .find or .sql
source code
 
reindex(yo) source code
 
rename_field(yo, oldname, newname)
renames an existing field
source code
 
resize_field(yo, doomed, new_size)
resizes field (C only at this time) creates backup file, then modifies current structure
source code
 
size(yo, field)
returns size of field as a tuple of (length, decimals)
source code
 
sql(yo, command)
passes calls through to module level sql function
source code
 
structure(yo, fields=None)
return 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 = 'basic memory table'
  _versionabbv = 'dbf'
  _fieldtypes = {'D': {'Blank': <bound method type.today of <cla...
  _memoext = ''
  _memotypes = ('M')
  _yesMemoMask = ''
  _noMemoMask = ''
  _fixed_fields = ('M', 'D', 'L')
  _variable_fields = ()
  _character_fields = ('M')
  _decimal_fields = ()
  _numeric_fields = ()
  _currency_fields = ()
  _dbfTableHeader = '\x00\x00\x00\x00\x00\x00\x00\x00!\x00\x01\x...
  _dbfTableHeaderExtra = ''
  _supported_tables = []
  _read_only = False
  _meta_only = False
  _use_deleted = True
  backup = False
  codepage = <dbf.tables.property object at 0x00F08F10>
  field_count = <dbf.tables.property object at 0x00F08F30>
  field_names = <dbf.tables.property object at 0x00F08F50>
  filename = <dbf.tables.property object at 0x00F08F70>
  last_update = <dbf.tables.property object at 0x00F08F90>
  memoname = <dbf.tables.property object at 0x00F08FB0>
  record_length = <dbf.tables.property object at 0x00F08FD0>
  record_number = <dbf.tables.property object at 0x00F08FF0>
  supported_tables = <dbf.tables.property object at 0x00F0F030>
  use_deleted = <dbf.tables.property object at 0x00F0F050>
  version = <dbf.tables.property object at 0x00F0F070>
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(yo, filename=':memory:', field_specs=None, memo_size=128, ignore_memos=False, read_only=False, keep_memos=False, meta_only=False, codepage=None, numbers='default', strings=<type 'str'>, currency=<class 'decimal.Decimal'>)
(Constructor)

source code 

open/create dbf file filename should include path if needed field_specs can be either a ;-delimited string or a list of strings memo_size is always 512 for db3 memos ignore_memos is useful if the memo file is missing or corrupt read_only will load records into memory, then close the disk file keep_memos will also load any memo fields into memory meta_only will ignore all records, keeping only basic table information codepage will override whatever is set in the table itself

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)

structure(yo, fields=None)

source code 

return list of fields suitable for creating same table layout

Parameters:
  • fields - list of fields or None for all fields

Class Variable Details [hide private]

_fieldtypes

Value:
{'D': {'Blank': <bound method type.today of <class 'dbf.dates.Date'>>,
       'Class': None,
       'Init': <function addDate at 0x00F05BB0>,
       'Retrieve': <function retrieveDate at 0x00F05770>,
       'Type': 'Date',
       'Update': <function updateDate at 0x00F057B0>},
 'L': {'Blank': <type 'bool'>,
       'Class': None,
...

_dbfTableHeader

Value:
'\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\x00\x00\x00'