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

Class Table

source code

 object --+    
          |    
_Navigation --+
              |
             Table
Known Subclasses:

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()
Lives in the class, and on first access calls the supplied factory and maps the result into the instance it was called on
source code
 
_previous_status()
Lives in the class, and on first access calls the supplied factory and maps the result into the instance it was called on
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
 
__nonzero__(self)
True if table has any records
source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
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='', 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 (dbf type, class, size, dec) 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: bottom, goto, 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
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
Class Variables [hide private]
  _version = 'basic memory table'
  _versionabbr = 'dbf'
  _max_fields = 255
  _max_records = 4294967296
  _memoext = ''
  _yesMemoMask = ''
  _noMemoMask = ''
  _binary_types = ()
  _character_types = ('C', 'D', 'F', 'L', 'M', 'N')
  _currency_types = ()
  _date_types = ('D')
  _datetime_types = ()
  _decimal_types = ('N', 'F')
  _fixed_types = ('M', 'D', 'L')
  _logical_types = ('L')
  _memo_types = ('M')
  _numeric_types = ('N', 'F')
  _variable_types = ('C', 'N', 'F')
  _dbfTableHeader = '\x00\x00\x00\x00\x00\x00\x00\x00!\x00\x01\x...
  _dbfTableHeaderExtra = ''
  _supported_tables = []
  _pack_count = 0
  backup = None
hash(x)

Inherited from _Navigation (private): _index

Properties [hide private]
  codepage
code page used for text translation
  field_count
the number of user fields in the table
  field_names
a list of the user fields in the table
  filename
table's file name, including path (if specified on open)
  last_update
date of last update
  memoname
table's memo name (if path included in filename on open)
  record_length
number of bytes in a record (including deleted flag and null field size
  supported_tables
allowable table types
  status
CLOSED, READ_ONLY, or READ_WRITE
  version
returns the dbf type of the table

Inherited from _Navigation: bof, current, current_record, eof, first_record, last_record, next_record, prev_record

Inherited from object: __class__

Method Details [hide private]

_field_types()

source code 

Lives in the class, and on first access calls the supplied factory and maps the result into the instance it was called on

Decorators:
  • @MutableDefault

_previous_status()

source code 

Lives in the class, and on first access calls the supplied factory and maps the result into the instance it was called on

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)
Static Method

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)

Class Variable Details [hide private]

_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'

Property Details [hide private]

codepage

code page used for text translation

Get Method:
unreachable.codepage(self) - code page used for text translation
Set Method:
unreachable.codepage(self, codepage)

field_count

the number of user fields in the table

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

field_names

a list of the user fields in the table

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

filename

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

Get Method:
unreachable.filename(self) - table's file name, including path (if specified on open)

last_update

date of last update

Get Method:
unreachable.last_update(self) - date of last update

memoname

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

Get Method:
unreachable.memoname(self) - table's memo name (if path included in filename on open)

record_length

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

Get Method:
unreachable.record_length(self) - number of bytes in a record (including deleted flag and null field size

supported_tables

allowable table types

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

status

CLOSED, READ_ONLY, or READ_WRITE

Get Method:
unreachable.status(self) - CLOSED, READ_ONLY, or READ_WRITE

version

returns the dbf type of the table

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