Package dbf
[hide private]
[frames] | no frames]

Package dbf

source code

Submodules [hide private]

Classes [hide private]
  fake_module
  BadDataError
bad data in table
  Bof
Beginning of file reached
  Char
Strips trailing whitespace, and ignores trailing whitespace for comparisons
  CodePage
tuple with named attributes for representing a tables codepage
  DataOverflowError
Data too large for field
  Date
adds null capable datetime.date constructs
  DateTime
adds null capable datetime.datetime constructs
  DbfError
Fatal errors elicit this response.
  DbfWarning
Normal operations elicit this response
  Decimal
Floating point class for decimal arithmetic.
  DoNotIndex
Returned by indexing functions to suppress a record from becoming part of the index
  Eof
End of file reached
  FieldMissingError
Field does not exist in table
  FieldSpecError
invalid field specification
  Index
non-persistent index for a table
  IndexLocation
Represents the index where the match criteria is if True, or would be if False
  Iter
Provides iterable behavior for a table
  List
list of Dbf records, with set-like behavior
  Logical
Logical field return type.
  NonUnicodeError
Data for table not in unicode
  NoneType
  NotFoundError
record criteria not met
  Period
for matching various time ranges
  Quantum
Logical field return type that implements boolean algebra
  Record
Provides routines to extract and save data within the fields of a dbf record.
  Relation
establishes a relation between two dbf tables (not persistent)
  Table
Base class for dbf style tables
  Time
adds null capable datetime.time constructs
Functions [hide private]
 
Process(records, start=0, stop=None, filter=None)
commits each record to disk before returning the next one; undoes all changes to that record if exception raised if records is a table, it will be opened and closed if necessary filter function should return True to skip record, False to keep
source code
 
Templates(records, start=0, stop=None, filter=None)
returns a template of each record instead of the record itself if records is a table, it will be opened and closed if necessary
source code
 
add_fields(table_name, field_specs)
adds fields to an existing table
source code
 
create_template(table_or_record, defaults=None) source code
 
delete(record)
marks record as deleted
source code
 
delete_fields(table_name, field_names)
deletes fields from an existing table
source code
 
export(table_or_records, filename=None, field_names=None, format='csv', header=True, dialect='dbf', encoding=None)
writes the records using CSV or tab-delimited format, using the filename given if specified, otherwise the table name if table_or_records is a collection of records (not an actual table) they should all be of the same format
source code
 
field_names(thing)
fields in table/record, keys in dict
source code
 
first_record(table_name)
prints the first record of a table
source code
 
from_csv(csvfile, to_disk=False, filename=None, field_names=None, extra_fields=None, dbf_type='db3', memo_size=64, min_field_size=1, encoding=None, errors=None)
creates a Character table from a csv file to_disk will create a table with the same name filename will be used if provided field_names default to f0, f1, f2, etc, unless specified (list) extra_fields can be used to add additional fields -- should be normal field specifiers (list)
source code
 
gather(record, data, drop=False)
saves data into a record's fields; writes to disk if not in flux keys with no matching field will raise a FieldMissingError exception unless drop_missing == True; if an Exception occurs the record is restored before reraising
source code
 
get_fields(table_name)
returns the list of field names of a table
source code
 
guess_table_type(filename) source code
 
info(table_name)
prints table info
source code
 
is_deleted(record)
marked for deletion?
source code
 
recno(record)
physical record number
source code
 
rename_field(table_name, oldfield, newfield)
renames a field in a table
source code
 
reset(record, keep_fields=None)
sets record's fields back to original, except for fields in keep_fields
source code
 
scatter(record, as_type=<function create_template at 0x7ffff61d6488>, _mappings=<class '_abcoll.Mapping'>)
returns as_type() of [fieldnames and] values.
source code
 
source_table(thingie)
table associated with table | record | index
source code
 
structure(table_name, field=None)
returns the definition of a field (or all fields)
source code
 
table_type(filename)
returns text representation of a table's dbf version
source code
 
undelete(record)
marks record as active
source code
Variables [hide private]
  version = (0, 96, 3)
  module = {'BINARY': 4, 'BadDataError': <class 'dbf.ver_2.BadDa...
  BINARY = 4
  CLASS = 6
  CLOSED = 'closed'
  DECIMALS = 4
  EMPTY = 7
  END = 3
  FIELD_FLAGS = {1: 'system', 2: 'null', 4: 'binary', 'binary': ...
  FLAGS = 5
  Falsth = Logical('F')
  IN_MEMORY = 0
  LAST_APRIL = <RelativeMonth.NEXT_JUNE: ()>
  LAST_AUGUST = <RelativeMonth.NEXT_JUNE: ()>
  LAST_DECEMBER = <RelativeMonth.NEXT_JUNE: ()>
  LAST_FEBRUARY = <RelativeMonth.NEXT_JUNE: ()>
  LAST_FRIDAY = <RelativeDay.LAST_SUNDAY: ()>
  LAST_JANUARY = <RelativeMonth.NEXT_JUNE: ()>
  LAST_JULY = <RelativeMonth.NEXT_JUNE: ()>
  LAST_JUNE = <RelativeMonth.NEXT_JUNE: ()>
  LAST_MARCH = <RelativeMonth.NEXT_JUNE: ()>
  LAST_MAY = <RelativeMonth.NEXT_JUNE: ()>
  LAST_MONDAY = <RelativeDay.LAST_SUNDAY: ()>
  LAST_NOVEMBER = <RelativeMonth.NEXT_JUNE: ()>
  LAST_OCTOBER = <RelativeMonth.NEXT_JUNE: ()>
  LAST_SATURDAY = <RelativeDay.LAST_SUNDAY: ()>
  LAST_SEPTEMBER = <RelativeMonth.NEXT_JUNE: ()>
  LAST_SUNDAY = <RelativeDay.LAST_SUNDAY: ()>
  LAST_THURSDAY = <RelativeDay.LAST_SUNDAY: ()>
  LAST_TUESDAY = <RelativeDay.LAST_SUNDAY: ()>
  LAST_WEDNESDAY = <RelativeDay.LAST_SUNDAY: ()>
  LENGTH = 2
  LOGICAL_BAD_IS_NONE = True
hash(x)
  NEXT_APRIL = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_AUGUST = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_DECEMBER = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_FEBRUARY = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_FRIDAY = <RelativeDay.LAST_SUNDAY: ()>
  NEXT_JANUARY = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_JULY = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_JUNE = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_MARCH = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_MAY = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_MONDAY = <RelativeDay.LAST_SUNDAY: ()>
  NEXT_NOVEMBER = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_OCTOBER = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_SATURDAY = <RelativeDay.LAST_SUNDAY: ()>
  NEXT_SEPTEMBER = <RelativeMonth.NEXT_JUNE: ()>
  NEXT_SUNDAY = <RelativeDay.LAST_SUNDAY: ()>
  NEXT_THURSDAY = <RelativeDay.LAST_SUNDAY: ()>
  NEXT_TUESDAY = <RelativeDay.LAST_SUNDAY: ()>
  NEXT_WEDNESDAY = <RelativeDay.LAST_SUNDAY: ()>
  NULL = 8
  NULLABLE = 2
  Null = <null>
  NullDate = Date()
  NullDateTime = DateTime()
  NullTime = Time()
  ON_DISK = 1
  Off = Quantum('N')
  On = Quantum('Y')
  Other = Quantum('?')
  READ_ONLY = 'read-only'
  READ_WRITE = 'read-write'
  SEEK_CUR = 1
  SEEK_END = 2
  SEEK_SET = 0
  START = 1
  SYSTEM = 1
  TYPE = 0
  Truth = Logical('T')
  Unknown = Logical('?')
  VFPTIME = 1721425
  Vapor = Vapor()
  _DeadObject = _DeadObject()
  _Template_Records = {}
  __package__ = 'dbf'
  baseinteger = (<type 'int'>, <type 'long'>)
  basestring = (<type 'str'>, <type 'unicode'>, <class 'dbf.ver_...
  code_pages = {'\x00': ('ascii', 'plain ol\' ascii'), '\x01': (...
  days_per_leap_month = [31, 31, 29, 31, 30, 31, 30, 31, 31, 30,...
  days_per_month = [31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, ...
  default_codepage = 'ascii'
  default_type = 'db3'
  input_decoding = 'ascii'
  name = 'write'
  pql_functions = {'select': pql_select, 'update': pql_update, '...
  pql_user_functions = {}
  py_ver = (2, 7)
  table_types = {'clp': <class 'dbf.ver_2.ClpTable'>, 'db3': <cl...
  temp_dir = ''
  version_map = {'\x02': 'FoxBASE', '\x03': 'dBase III Plus', '\...
Variables Details [hide private]

module

Value:
{'BINARY': 4,
 'BadDataError': <class 'dbf.ver_2.BadDataError'>,
 'Bof': <class 'dbf.ver_2.Bof'>,
 'Bytes': <class 'dbf.ver_2.Bytes'>,
 'BytesType': <class 'dbf.ver_2.BytesType'>,
 'CLASS': 6,
 'CLOSED': 'closed',
 'Char': <class 'dbf.ver_2.Char'>,
...

FIELD_FLAGS

Value:
{1: 'system',
 2: 'null',
 4: 'binary',
 'binary': 4,
 'nocptrans': 4,
 'null': 2}

basestring

Value:
(<type 'str'>, <type 'unicode'>, <class 'dbf.ver_2.Char'>)

code_pages

Value:
{'\x00': ('ascii', 'plain ol\' ascii'),
 '\x01': ('cp437', 'U.S. MS-DOS'),
 '\x02': ('cp850', 'International MS-DOS'),
 '\x03': ('cp1252', 'Windows ANSI'),
 '\x04': ('mac_roman', 'Standard Macintosh'),
 '\x08': ('cp865', 'Danish OEM'),
 '\t': ('cp437', 'Dutch OEM'),
 '''
...

days_per_leap_month

Value:
[31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31]

days_per_month

Value:
[31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31]

pql_functions

Value:
{'select': pql_select, 'update': pql_update, 'replace': pql_update, 'i\
nsert': None, 'delete': pql_delete, 'recall': pql_recall, 'add': pql_a\
dd, 'drop': pql_drop, 'count': None, 'pack': pql_pack, 'resize': pql_r\
esize,}

table_types

Value:
{'clp': <class 'dbf.ver_2.ClpTable'>,
 'db3': <class 'dbf.ver_2.Db3Table'>,
 'fp': <class 'dbf.ver_2.FpTable'>,
 'vfp': <class 'dbf.ver_2.VfpTable'>}

version_map

Value:
{'\x02': 'FoxBASE',
 '\x03': 'dBase III Plus',
 '\x04': 'dBase IV',
 '\x05': 'dBase V',
 '0': 'Visual FoxPro',
 '1': 'Visual FoxPro (auto increment field)',
 '2': 'Visual FoxPro (VarChar, VarBinary, or BLOB enabled)',
 'C': 'dBase IV SQL table files',
...