Documentation ¶
Overview ¶
Package for working with dBase III plus database files.
1. Package provides both reflection-via-struct interface and direct Row()/FieldValueByName()/AddxxxField() interface. 2. Once table is created and rows added to it, table structure can not be modified. 3. Working with reflection-via-struct interface is easier and produces less verbose code. 4. Use Iterator to iterate over table since it skips deleted rows.
TODO: File is loaded and kept in-memory. Not a good design choice if file is huge. This should be changed to use buffers and keep some of the data on-disk in the future. Current API structure should allow redesign.
Typical usage db := dbf.New() or dbf.LoadFile(filename)
then use db.NewIterator() and iterate or db.Append()
do not forget db.SaveFile(filename) if you want changes saved.
Index ¶
- Variables
- type DbfField
- type DbfTable
- func (dt *DbfTable) AddBoolField(fieldName string) error
- func (dt *DbfTable) AddDateField(fieldName string) error
- func (dt *DbfTable) AddFloatField(fieldName string) error
- func (dt *DbfTable) AddIntField(fieldName string) error
- func (dt *DbfTable) AddNumberField(fieldName string, length uint8, prec uint8) error
- func (dt *DbfTable) AddRecord() int
- func (dt *DbfTable) AddTextField(fieldName string, length uint8) error
- func (dt *DbfTable) Append(spec interface{}) int
- func (dt *DbfTable) Create(spec interface{}) error
- func (dt *DbfTable) Delete(row int)
- func (dt *DbfTable) FieldValue(row int, fieldIndex int) string
- func (dt *DbfTable) FieldValueByName(row int, fieldName string) string
- func (dt *DbfTable) Fields() []DbfField
- func (dt *DbfTable) InsertRecord() int
- func (dt *DbfTable) IsDeleted(row int) bool
- func (dt *DbfTable) NewIterator() *Iterator
- func (dt *DbfTable) NumRecords() int
- func (dt *DbfTable) Read(row int, spec interface{}) error
- func (dt *DbfTable) Row(row int) []string
- func (dt *DbfTable) SaveFile(filename string) error
- func (dt *DbfTable) SetFieldValue(row int, fieldIndex int, value string)
- func (dt *DbfTable) SetFieldValueByName(row int, fieldName string, value string)
- func (dt *DbfTable) Write(row int, spec interface{}) int
- type Iterator
Constants ¶
This section is empty.
Variables ¶
var Version = struct { major, minor, build int }{ 1, 0, 2, }
last mod 02/14/2016
Functions ¶
This section is empty.
Types ¶
type DbfField ¶
type DbfField struct { Name string Type string Length uint8 // contains filtered or unexported fields }
func (*DbfField) SetFieldName ¶
type DbfTable ¶
type DbfTable struct {
// contains filtered or unexported fields
}
func (*DbfTable) AddBoolField ¶
Boolean field stores 't' or 'f' in the cell.
func (*DbfTable) AddDateField ¶
func (*DbfTable) AddFloatField ¶
AddFloatField add float.
func (*DbfTable) AddIntField ¶
AddIntField add int.
func (*DbfTable) AddNumberField ¶
AddNumberField can be used to add int or float number fields.
func (*DbfTable) AddTextField ¶
AddTextField max size 254 bytes.
func (*DbfTable) FieldValueByName ¶
FieldValueByName retuns the value of a field given row number and fieldName provided.
func (*DbfTable) InsertRecord ¶
InsertRecord tries to reuse deleted records, and only then add new record to the end of file if no delete slots exist. If you are looping over rows it is better to use AddRecord.
func (*DbfTable) NewIterator ¶
func (*DbfTable) NumRecords ¶
NumRecords return number of rows in dbase table.
func (*DbfTable) SetFieldValue ¶
Sets field value by index.
func (*DbfTable) SetFieldValueByName ¶
Sets field value by name.