Package dbf :: Module ver_32 :: Class Table
[hide private]
[frames] | no frames]

Class Table

source code

 object --+    
          |    
_Navigation --+
              |
             Table

Base class 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
  _Indexen
implements the weakref structure for seperate indexes
  _MetaData
Container class for storing per table metadata
  _TableHeader
represents the data block that defines a tables type and layout
  _Table
implements the weakref table for records
Instance Methods [hide private]
 
_field_types() source code
 
_previous_status() source code
 
_build_header_fields(self)
constructs fieldblock for disk table
source code
 
_check_memo_integrity(self)
checks memo file for problems
source code
 
_initialize_fields(self)
builds the FieldList of names, types, and descriptions from the disk file
source code
 
_field_layout(self, i)
Returns field information Name Type(Length[, Decimals])
source code
 
_list_fields(self, specs, sep=',')
standardizes field specs
source code
 
_nav_check(self)
Raises `DbfError` if table is closed
source code
 
_update_disk(self, headeronly=False)
synchronizes the disk file with current data
source code
 
__contains__(self, data)
data can be a record, template, dict, or tuple
source code
 
__enter__(self) source code
 
__exit__(self, *exc_info) source code
 
__getattr__(self, name) source code
 
__getitem__(self, value) source code
 
__init__(self, filename, field_specs=None, memo_size=128, ignore_memos=False, codepage=None, default_data_types=None, field_data_types=None, dbf_type=None, on_disk=True)
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__(self)
iterates over the table's records
source code
 
__len__(self)
returns number of records in table
source code
a new object with type S, a subtype of T
__new__(cls, filename, field_specs=None, memo_size=128, ignore_memos=False, codepage=None, default_data_types=None, field_data_types=None, dbf_type=None, on_disk=True) source code
 
__bool__(self)
True if table has any records
source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code
 
codepage(self, codepage) source code
 
field_count(self)
the number of user fields in the table
source code
 
field_names(self)
a list of the user fields in the table
source code
 
filename(self)
table's file name, including path (if specified on open)
source code
 
last_update(self)
date of last update
source code
 
memoname(self)
table's memo name (if path included in filename on open)
source code
 
record_length(self)
number of bytes in a record (including deleted flag and null field size
source code
 
supported_tables(self)
allowable table types
source code
 
status(self)
CLOSED, READ_ONLY, or READ_WRITE
source code
 
version(self)
returns the dbf type of the table
source code
 
add_fields(self, 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 zaps table, recreates current structure, and copies records back from the backup
source code
 
allow_nulls(self, fields)
set fields to allow null values
source code
 
append(self, data=b'', drop=False, multiple=1)
adds <multiple> blank records, and fills fields with dict/tuple values if present
source code
 
close(self)
closes disk files, flushing record data to disk ensures table data is available if keep_table ensures memo data is available if keep_memos
source code
 
create_backup(self, new_name=None, on_disk=None)
creates a backup table
source code
 
create_index(self, key)
creates an in-memory index using the function key
source code
 
create_template(self, record=None, defaults=None)
returns a record template that can be used like a record
source code
 
delete_fields(self, doomed)
removes field(s) from the table creates backup files with _backup appended to the file name, then modifies current structure
source code
 
disallow_nulls(self, fields)
set fields to not allow null values
source code
 
field_info(self, field)
returns (field type, size, dec, class) of field
source code
 
index(self, record, start=None, stop=None)
returns the index of record between start and stop start and stop default to the first and last record
source code
 
new(self, filename, field_specs=None, memo_size=None, ignore_memos=None, codepage=None, default_data_types=None, field_data_types=None, on_disk=True)
returns a new table of the same type
source code
 
nullable_field(self, field)
returns True if field allows Nulls
source code
 
open(self, mode=READ_WRITE)
(re)opens disk table, (re)initializes data structures
source code
 
pack(self)
physically removes all deleted records
source code
 
query(self, criteria)
criteria is a string that will be converted into a function that returns a List of all matching records
source code
 
reindex(self)
reprocess all indices for this table
source code
 
rename_field(self, oldname, newname)
renames an existing field
source code
 
resize_field(self, chosen, new_size)
resizes field (C only at this time) creates backup file, then modifies current structure
source code
 
structure(self, fields=None)
return field specification list suitable for creating same table layout fields should be a list of fields or None for all fields in table
source code
 
zap(self)
removes all records from table -- this cannot be undone!
source code

Inherited from _Navigation: bof, bottom, current, current_record, eof, first_record, goto, last_record, next_record, prev_record, skip, top

Inherited from _Navigation (private): _get_index

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Static Methods [hide private]
 
_pack_date(date)
Returns a group of three bytes, in integer form, of the date
source code
 
_unpack_date(bytestr)
Returns a Date() of the packed three-byte date passed in
source code
Class Variables [hide private]
  _version = 'basic memory table'
  _versionabbr = 'dbf'
  _max_fields = 255
  _max_records = 4294967296
  _memoext = ''
  _yesMemoMask = 0
  _noMemoMask = 0
  _binary_types = tuple()
  _character_types = CHAR, DATE, FLOAT, LOGICAL, MEMO, NUMERIC
  _currency_types = tuple()
  _date_types = DATE,
  _datetime_types = tuple()
  _decimal_types = NUMERIC, FLOAT
  _fixed_types = MEMO, DATE, LOGICAL
  _logical_types = LOGICAL,
  _memo_types = MEMO,
  _numeric_types = NUMERIC, FLOAT
  _variable_types = CHAR, NUMERIC, FLOAT
  _dbfTableHeader = _dbfTableHeader.tobytes()
  _dbfTableHeaderExtra = b''
  _supported_tables = ()
  _pack_count = 0
  backup = None
hash(x)

Inherited from _Navigation (private): _index

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_field_types()

source code 
Decorators:
  • @MutableDefault

_previous_status()

source code 
Decorators:
  • @MutableDefault

_nav_check(self)

source code 

Raises `DbfError` if table is closed

Overrides: _Navigation._nav_check

__init__(self, filename, field_specs=None, memo_size=128, ignore_memos=False, codepage=None, default_data_types=None, field_data_types=None, dbf_type=None, on_disk=True)
(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__

__new__(cls, filename, field_specs=None, memo_size=128, ignore_memos=False, codepage=None, default_data_types=None, field_data_types=None, dbf_type=None, on_disk=True)

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

codepage(self, codepage)

source code 
Decorators:
  • @codepage.setter

field_count(self)

source code 

the number of user fields in the table

Decorators:
  • @property

field_names(self)

source code 

a list of the user fields in the table

Decorators:
  • @property

filename(self)

source code 

table's file name, including path (if specified on open)

Decorators:
  • @property

last_update(self)

source code 

date of last update

Decorators:
  • @property

memoname(self)

source code 

table's memo name (if path included in filename on open)

Decorators:
  • @property

record_length(self)

source code 

number of bytes in a record (including deleted flag and null field size

Decorators:
  • @property

supported_tables(self)

source code 

allowable table types

Decorators:
  • @property

status(self)

source code 

CLOSED, READ_ONLY, or READ_WRITE

Decorators:
  • @property

version(self)

source code 

returns the dbf type of the table

Decorators:
  • @property