Package dbf
[hide private]

Package dbf

source code

Copyright

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY Ad-Mail, Inc ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Ad-Mail, Inc BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Summary

Python package for reading/writing dBase III and VFP 6 tables and memos

The entire table is read into memory, and all operations occur on the in-memory table, with data changes being written to disk as they occur.

Goals: programming style with databases

NOTE: Of the VFP data types, auto-increment and null settings are not implemented.

Submodules [hide private]

Functions [hide private]
 
Table(filename, field_specs='', memo_size=128, ignore_memos=False, read_only=False, keep_memos=False, meta_only=False, dbf_type=None, codepage=None, numbers='default', strings=<type 'str'>, currency=<class 'decimal.Decimal'>)
returns an open table of the correct dbf_type, or creates it if field_specs is given
source code
 
index(sequence)
returns integers 0 - len(sequence)
source code
 
guess_table_type(filename) source code
 
table_type(filename)
returns text representation of a table's dbf version
source code
 
add_fields(table, field_specs)
adds fields to an existing table
source code
 
delete_fields(table, field_names)
deletes fields from an existing table
source code
 
export(table, filename='', fields='', format='csv', header=True)
creates a csv or tab-delimited file from an existing table
source code
 
first_record(table)
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)
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
 
get_fields(table)
returns the list of field names of a table
source code
 
info(table)
prints table info
source code
 
rename_field(table, oldfield, newfield)
renames a field in a table
source code
 
structure(table, field=None)
returns the definition of a field (or all fields)
source code
 
hex_dump(records)
just what it says ;)
source code
Variables [hide private]
  version = (0, 88, 20)
  default_type = 'db3'
  sql_user_functions = {}
  table_types = {'db3': <class 'dbf.tables.Db3Table'>, 'dbf': <c...

Imports: os, csv, Date, DateTime, Time, DbfWarning, Bof, Eof, DbfError, DataOverflow, FieldMissing, DoNotIndex, DbfTable, Db3Table, VfpTable, FpTable, List, DbfCsv, sql, ascii, codepage, encoding, version_map, Decimal, _io, dates, exceptions, tables


Variables Details [hide private]

table_types

Value:
{'db3': <class 'dbf.tables.Db3Table'>,
 'dbf': <class 'dbf.tables.DbfTable'>,
 'fp': <class 'dbf.tables.FpTable'>,
 'vfp': <class 'dbf.tables.VfpTable'>}