Documentation ¶
Overview ¶
This go-dbase package offers tools for managing dBase-format database files. It supports tailored I/O operations for Unix and Windows platforms, provides flexible data representations like maps, JSON, and Go structs, and ensures safe concurrent operations with built-in mutex locks.
The package facilitates defining, manipulating, and querying columns and rows in dBase tables, converting between dBase-specific data types and Go data types, and performing systematic error handling.
Typical use cases include data retrieval from legacy dBase systems, conversion of dBase files to modern formats, and building applications that interface with dBase databases.
Index ¶
- Constants
- Variables
- func Debug(enabled bool, out io.Writer)
- func RegisterCustomEncoding(codePageMark byte, encoding encoding.Encoding)
- func ValidateFileVersion(version byte, untested bool) error
- type Column
- type ColumnFlag
- type Config
- type DataType
- type Database
- type DefaultConverter
- type EncodingConverter
- type Error
- type Field
- type File
- func (file *File) BOF() bool
- func (file *File) BytesToRow(data []byte) (*Row, error)
- func (file *File) Close() error
- func (file *File) Column(pos int) *Column
- func (file *File) ColumnNames() []string
- func (file *File) ColumnPos(column *Column) int
- func (file *File) ColumnPosByName(colname string) int
- func (file *File) Columns() []*Column
- func (file *File) ColumnsCount() uint16
- func (file *File) Create() error
- func (file *File) Deleted() (bool, error)
- func (file *File) EOF() bool
- func (file *File) GetColumnModification(position int) *Modification
- func (file *File) GetHandle() (interface{}, interface{})
- func (file *File) GetIO() IO
- func (file *File) GoTo(row uint32) error
- func (file *File) Header() *Header
- func (file *File) Init() error
- func (file *File) Interpret(raw []byte, column *Column) (interface{}, error)
- func (file *File) NewField(pos int, value interface{}) (*Field, error)
- func (file *File) NewFieldByName(name string, value interface{}) (*Field, error)
- func (file *File) NewRow() *Row
- func (file *File) Next() (*Row, error)
- func (file *File) Pointer() uint32
- func (file *File) ReadColumns() ([]*Column, *Column, error)
- func (file *File) ReadHeader() error
- func (file *File) ReadMemo(address []byte) ([]byte, bool, error)
- func (file *File) ReadMemoHeader() error
- func (file *File) ReadNullFlag(position uint64, column *Column) (bool, bool, error)
- func (file *File) ReadRow(position uint32) ([]byte, error)
- func (file *File) Represent(field *Field, padding bool) ([]byte, error)
- func (file *File) Row() (*Row, error)
- func (file *File) RowFromJSON(j []byte) (*Row, error)
- func (file *File) RowFromMap(m map[string]interface{}) (*Row, error)
- func (file *File) RowFromStruct(v interface{}) (*Row, error)
- func (file *File) Rows(skipInvalid bool, skipDeleted bool) ([]*Row, error)
- func (file *File) RowsCount() uint32
- func (file *File) Search(field *Field, exactMatch bool) ([]*Row, error)
- func (file *File) SetColumnModification(position int, mod *Modification)
- func (file *File) SetColumnModificationByName(name string, mod *Modification) error
- func (file *File) Skip(offset int64)
- func (file *File) TableName() string
- func (file *File) WriteColumns() error
- func (file *File) WriteHeader() error
- func (file *File) WriteMemo(data []byte, text bool, length int) ([]byte, error)
- func (file *File) WriteMemoHeader(size int) error
- func (file *File) WriteRow(row *Row) error
- type FileExtension
- type FileVersion
- type GenericIO
- func (g GenericIO) Close(file *File) error
- func (g GenericIO) Create(file *File) error
- func (g GenericIO) Deleted(file *File) (bool, error)
- func (g GenericIO) GoTo(file *File, row uint32) error
- func (g GenericIO) OpenTable(config *Config) (*File, error)
- func (g GenericIO) ReadColumns(file *File) ([]*Column, *Column, error)
- func (g GenericIO) ReadHeader(file *File) error
- func (g GenericIO) ReadMemo(file *File, address []byte) ([]byte, bool, error)
- func (g GenericIO) ReadMemoHeader(file *File) error
- func (g GenericIO) ReadNullFlag(file *File, position uint64, column *Column) (bool, bool, error)
- func (g GenericIO) ReadRow(file *File, position uint32) ([]byte, error)
- func (g GenericIO) Search(file *File, field *Field, exactMatch bool) ([]*Row, error)
- func (g GenericIO) Skip(file *File, offset int64)
- func (g GenericIO) WriteColumns(file *File) error
- func (g GenericIO) WriteHeader(file *File) error
- func (g GenericIO) WriteMemo(file *File, raw []byte, text bool, length int) ([]byte, error)
- func (g GenericIO) WriteMemoHeader(file *File, size int) error
- func (g GenericIO) WriteRow(file *File, row *Row) error
- type Header
- type IO
- type Marker
- type MemoHeader
- type Modification
- type Row
- func (row *Row) Add() error
- func (row *Row) BoolValueByName(name string) (bool, error)
- func (row *Row) BytesValueByName(name string) ([]byte, error)
- func (row *Row) Field(pos int) *Field
- func (row *Row) FieldByName(name string) *Field
- func (row *Row) Fields() []*Field
- func (row *Row) FloatValueByName(name string) (float64, error)
- func (row *Row) Increment() error
- func (row *Row) IntValueByName(name string) (int64, error)
- func (row *Row) MustBoolValueByName(name string) bool
- func (row *Row) MustBytesValueByName(name string) []byte
- func (row *Row) MustFloatValueByName(name string) float64
- func (row *Row) MustIntValueByName(name string) int64
- func (row *Row) MustStringValueByName(name string) string
- func (row *Row) MustTimeValueByName(name string) time.Time
- func (row *Row) MustValueByName(name string) interface{}
- func (row *Row) StringValueByName(name string) (string, error)
- func (row *Row) TimeValueByName(name string) (time.Time, error)
- func (row *Row) ToBytes() ([]byte, error)
- func (row *Row) ToJSON() ([]byte, error)
- func (row *Row) ToMap() (map[string]interface{}, error)
- func (row *Row) ToStruct(v interface{}) error
- func (row *Row) Value(pos int) interface{}
- func (row *Row) ValueByName(name string) (interface{}, error)
- func (row *Row) Values() []interface{}
- func (row *Row) Write() error
- type Table
- type TableFlag
- type UnixIO
- func (u UnixIO) Close(file *File) error
- func (u UnixIO) Create(file *File) error
- func (u UnixIO) Deleted(file *File) (bool, error)
- func (u UnixIO) GoTo(file *File, row uint32) error
- func (u UnixIO) OpenTable(config *Config) (*File, error)
- func (u UnixIO) ReadColumns(file *File) ([]*Column, *Column, error)
- func (u UnixIO) ReadHeader(file *File) error
- func (u UnixIO) ReadMemo(file *File, blockdata []byte) ([]byte, bool, error)
- func (u UnixIO) ReadMemoHeader(file *File) error
- func (u UnixIO) ReadNullFlag(file *File, rowPosition uint64, column *Column) (bool, bool, error)
- func (u UnixIO) ReadRow(file *File, position uint32) ([]byte, error)
- func (u UnixIO) Search(file *File, field *Field, exactMatch bool) ([]*Row, error)
- func (u UnixIO) Skip(file *File, offset int64)
- func (u UnixIO) WriteColumns(file *File) error
- func (u UnixIO) WriteHeader(file *File) error
- func (u UnixIO) WriteMemo(file *File, raw []byte, text bool, length int) ([]byte, error)
- func (u UnixIO) WriteMemoHeader(file *File, size int) error
- func (u UnixIO) WriteRow(file *File, row *Row) error
Constants ¶
const ( MaxColumnNameLength = 10 MaxCharacterLength = 254 MaxNumericLength = 20 MaxFloatLength = 20 MaxIntegerValue = math.MaxInt32 MinIntegerValue = math.MinInt32 )
Variables ¶
var ( // Returned when the end of a dBase database file is reached ErrEOF = errors.New("EOF") // Returned when the row pointer is attempted to be moved before the first row ErrBOF = errors.New("BOF") // Returned when the read of a row or column did not finish ErrIncomplete = errors.New("INCOMPLETE") // Returned when a file operation is attempted on a non existent file ErrNoFPT = errors.New("FPT_FILE_NOT_FOUND") ErrNoDBF = errors.New("DBF_FILE_NOT_FOUND") // Returned when an invalid column position is used (x<1 or x>number of columns) ErrInvalidPosition = errors.New("INVALID_POSITION") ErrInvalidEncoding = errors.New("INVALID_ENCODING") // Returned when an invalid data type is used ErrUnknownDataType = errors.New("UNKNOWN_DATA_TYPE") )
Functions ¶
func Debug ¶ added in v1.7.1
Debug the dbase package If debug is true, debug messages will be printed to the defined io.Writter (default: os.Stdout)
func RegisterCustomEncoding ¶ added in v1.12.2
func ValidateFileVersion ¶ added in v1.9.0
Check if the file version is tested
Types ¶
type Column ¶
type Column struct { FieldName [11]byte // Column name with a maximum of 10 characters. If less than 10, it is padded with null characters (0x00). DataType byte // Column type Position uint32 // Displacement of column in row Length uint8 // Length of column (in bytes) Decimals uint8 // Number of decimal places Flag byte // Column flag Next uint32 // Value of autoincrement Next value Step uint16 // Value of autoincrement Step value Reserved [7]byte // Reserved }
Column is a struct containing the column information
func NewColumn ¶ added in v1.6.0
func NewColumn(name string, dataType DataType, length uint8, decimals uint8, nullable bool) (*Column, error)
Create a new column with the specified name, data type, length, decimals and nullable flag The length is only used for character, varbinary, varchar, numeric and float data types
type ColumnFlag ¶ added in v1.5.3
type ColumnFlag byte
Column flags indicate wether a column is hidden, can be null, is binary or is autoincremented
const ( HiddenFlag ColumnFlag = 0x01 NullableFlag ColumnFlag = 0x02 BinaryFlag ColumnFlag = 0x04 AutoincrementFlag ColumnFlag = 0x0C )
type Config ¶ added in v1.5.0
type Config struct { Filename string // The filename of the DBF file. Converter EncodingConverter // The encoding converter to use. Exclusive bool // If true the file is opened in exclusive mode. Untested bool // If true the file version is not checked. TrimSpaces bool // If true, spaces are trimmed from the start and end of string values. CollapseSpaces bool // If true, any length of spaces is replaced by a single space. DisableConvertFilenameUnderscores bool // If false underscores in the table filename are converted to spaces. ReadOnly bool // If true the file is opened in read-only mode. WriteLock bool // Whether or not the write operations should lock the record ValidateCodePage bool // Whether or not the code page mark should be validated. InterpretCodePage bool // Whether or not the code page mark should be interpreted. Ignores the defined converter. IO IO // The IO interface to use. }
Config is a struct containing the configuration for opening a Foxpro/dbase databse or table. The filename is mandatory.
The other fields are optional and are false by default. If Converter and InterpretCodePage are both not set the package will try to interpret the code page mark. To open untested files set Untested to true. Tested files are defined in the constants.go file.
type DataType ¶ added in v1.5.0
type DataType byte
DataType defines the possible types of a column
const ( Character DataType = 0x43 // C - Character (string) Currency DataType = 0x59 // Y - Currency (float64) Double DataType = 0x42 // B - Double (float64) Date DataType = 0x44 // D - Date (time.Time) DateTime DataType = 0x54 // T - DateTime (time.Time) Float DataType = 0x46 // F - Float (float64) Integer DataType = 0x49 // I - Integer (int32) Logical DataType = 0x4C // L - Logical (bool) Memo DataType = 0x4D // M - Memo (string) Numeric DataType = 0x4E // N - Numeric (int64) Blob DataType = 0x57 // W - Blob ([]byte) General DataType = 0x47 // G - General (string) Picture DataType = 0x50 // P - Picture (string) Varbinary DataType = 0x51 // Q - Varbinary ([]byte) Varchar DataType = 0x56 // V - Varchar (string) )
type Database ¶ added in v1.1.0
type Database struct {
// contains filtered or unexported fields
}
func OpenDatabase ¶ added in v1.7.0
OpenDatabase opens a dbase/foxpro database file and all related tables The database file must be a DBC file and the tables must be DBF files and in the same directory as the database
type DefaultConverter ¶ added in v1.6.2
type DefaultConverter struct {
// contains filtered or unexported fields
}
func ConverterFromCodePage ¶ added in v1.7.1
func ConverterFromCodePage(codePageMark byte) DefaultConverter
NewDefaultConverterFromCodePage returns a new EncodingConverter from a code page mark
func NewDefaultConverter ¶ added in v1.6.2
func NewDefaultConverter(encoding encoding.Encoding) DefaultConverter
func (DefaultConverter) CodePage ¶ added in v1.7.1
func (c DefaultConverter) CodePage() byte
CodePageMark returns corresponding code page mark for the encoding
type EncodingConverter ¶
type EncodingConverter interface { Decode(in []byte) ([]byte, error) Encode(in []byte) ([]byte, error) CodePage() byte }
EncodingConverter is an interface for encoding conversion between UTF8 and other encoding
type Error ¶ added in v1.1.0
type Error struct {
// contains filtered or unexported fields
}
Error is a wrapper for errors that occur in the dbase package
type Field ¶ added in v1.3.0
type Field struct {
// contains filtered or unexported fields
}
Field is a row data field
func (Field) GetValue ¶ added in v1.3.0
func (field Field) GetValue() interface{}
Value returns the field value
type File ¶ added in v1.7.0
type File struct {
// contains filtered or unexported fields
}
File is the main struct to handle a dBase file. Each file type is basically a Table or a Memo file.
func NewTable ¶ added in v1.11.0
func NewTable(version FileVersion, config *Config, columns []*Column, memoBlockSize uint16, io IO) (*File, error)
Create a new DBF file with the specified version, configuration and columns Please only use this for development and testing purposes and dont build new applications with it
func OpenTable ¶ added in v1.7.0
Opens a dBase database file (and the memo file if needed). The config parameter is required to specify the file path, encoding, file handles (IO) and others. If IO is nil, the default implementation is used depending on the OS.
func (*File) BytesToRow ¶ added in v1.7.0
Converts raw row data to a Row struct If the data points to a memo (FPT) file this file is also read
func (*File) ColumnNames ¶ added in v1.7.0
Returns a slice of all the column names
func (*File) ColumnPos ¶ added in v1.7.0
Returns the column position of a column or -1 if not found.
func (*File) ColumnPosByName ¶ added in v1.7.0
Returns the column position of a column by name or -1 if not found.
func (*File) ColumnsCount ¶ added in v1.7.0
Returns the number of columns
func (*File) Create ¶ added in v1.9.0
Creates a new dBase database file (and the memo file if needed).
func (*File) GetColumnModification ¶ added in v1.7.0
func (file *File) GetColumnModification(position int) *Modification
Returns the column modification for a column at the given position
func (*File) GetHandle ¶ added in v1.9.0
func (file *File) GetHandle() (interface{}, interface{})
Returns the used file handle (DBF,FPT)
func (*File) GoTo ¶ added in v1.7.0
GoTo sets the internal row pointer to row rowNumber Returns and EOF error if at EOF and positions the pointer at lastRow+1
func (*File) Init ¶ added in v1.11.5
Write creates the dbase files and writes the header and columns to it
func (*File) Interpret ¶ added in v1.9.0
Converts raw column data to the correct type for the given column For C and M columns a charset conversion is done For M columns the data is read from the memo file At this moment not all FoxPro column types are supported. When reading column values, the value returned by this package is always `interface{}`.
The supported column types with their return Go types are:
| Column Type | Column Type Name | Golang type | | ----------- | ---------------- | ----------- | | B | Double | float64 | | C | Character | string | | D | Date | time.Time | | F | Float | float64 | | I | Integer | int32 | | L | Logical | bool | | M | Memo | string | | M | Memo (Binary) | []byte | | N | Numeric (0 decimals) | int64 | | N | Numeric (with decimals) | float64 | | T | DateTime | time.Time | | Y | Currency | float64 |
Not all available column types have been implemented because we don't use them in our DBFs
func (*File) NewFieldByName ¶ added in v1.7.0
Creates a new field with the given value and column specified by name
func (*File) NewRow ¶ added in v1.7.0
Returns a new Row struct with the same column structure as the dbf and the next row pointer
func (*File) ReadColumns ¶ added in v1.9.0
ReadColumns reads from DBF header, starting at pos 32, until it finds the Header row terminator END_OF_COLUMN(0x0D).
func (*File) ReadHeader ¶ added in v1.9.0
Reads the DBF header from the file handle.
func (*File) ReadMemo ¶ added in v1.9.0
Reads one or more blocks from the FPT file, called for each memo column. the return value is the raw data and true if the data read is text (false is RAW binary data).
func (*File) ReadMemoHeader ¶ added in v1.9.0
ReadMemoHeader reads the memo header from the given file handle.
func (*File) ReadNullFlag ¶ added in v1.9.0
Read the nullFlag field at the end of the row The nullFlag field indicates if the field has a variable length If varlength is true, the field is variable length and the length is stored in the last byte If varlength is false, we read the complete field If the field is null, we return true as second return value
func (*File) Represent ¶ added in v1.11.0
Represent converts column data to the byte representation of the columns data type For M values the data is written to the memo file and the address is returned
func (*File) RowFromJSON ¶ added in v1.7.0
Converts a JSON-encoded row into the row representation
func (*File) RowFromMap ¶ added in v1.7.0
Converts a map of interfaces into the row representation
func (*File) RowFromStruct ¶ added in v1.7.0
Converts a struct into the row representation The struct must have the same field names as the columns in the table or the dbase tag must be set. The dbase tag can be used to name the field. For example: `dbase:"my_field_name"`
func (*File) Search ¶ added in v1.7.0
Search searches for a row with the given value in the given field
func (*File) SetColumnModification ¶ added in v1.7.0
func (file *File) SetColumnModification(position int, mod *Modification)
SetColumnModification sets a modification for a column
func (*File) SetColumnModificationByName ¶ added in v1.7.0
func (file *File) SetColumnModificationByName(name string, mod *Modification) error
func (*File) Skip ¶ added in v1.7.0
Skip adds offset to the internal row pointer If at end of file positions the pointer at lastRow+1 If the row pointer would be become negative positions the pointer at 0 Does not skip deleted rows
func (*File) WriteColumns ¶ added in v1.9.0
WriteColumns writes the columns at the end of header in dbase file
func (*File) WriteHeader ¶ added in v1.9.0
WriteHeader writes the header to the dbase file.
func (*File) WriteMemo ¶ added in v1.9.0
WriteMemo writes a memo to the memo file and returns the address of the memo.
func (*File) WriteMemoHeader ¶ added in v1.9.0
WriteMemoHeader writes the memo header to the memo file. Size is the number of blocks the new memo data will take up.
type FileExtension ¶ added in v1.6.2
type FileExtension string
Allowed file extensions for the different file types
const ( DBC FileExtension = ".DBC" // Database file extension DCT FileExtension = ".DCT" // Database container file extension DBF FileExtension = ".DBF" // Table file extension FPT FileExtension = ".FPT" // Memo file extension SCX FileExtension = ".SCX" // Form file extension LBX FileExtension = ".LBX" // Label file extension MNX FileExtension = ".MNX" // Menu file extension PJX FileExtension = ".PJX" // Project file extension RPX FileExtension = ".RPX" // Report file extension VCX FileExtension = ".VCX" // Visual class library file extension )
type FileVersion ¶ added in v1.7.0
type FileVersion byte
Supported and testet file versions - other files may work but are not tested The file version check has to be bypassed when opening a file type that is not supported https://learn.microsoft.com/en-us/previous-versions/visualstudio/foxpro/st4a0s68(v=vs.71)
const ( FoxPro FileVersion = 0x30 FoxProAutoincrement FileVersion = 0x31 FoxProVar FileVersion = 0x32 )
Supported and testet file types - other file types may work but are not tested
const ( FoxBase FileVersion = 0x02 FoxBase2 FileVersion = 0xFB FoxBasePlus FileVersion = 0x03 DBaseSQLTable FileVersion = 0x43 FoxBasePlusMemo FileVersion = 0x83 DBaseMemo FileVersion = 0x8B DBaseSQLMemo FileVersion = 0xCB FoxPro2Memo FileVersion = 0xF5 )
Not tested
type GenericIO ¶ added in v1.9.0
type GenericIO struct { Handle io.ReadWriteSeeker RelatedHandle io.ReadWriteSeeker }
GenericIO implements the IO interface for generic io.ReadWriteSeeker. Handle is the main file handle, relatedHandle is the memo file handle.
func (GenericIO) ReadColumns ¶ added in v1.9.0
func (GenericIO) ReadHeader ¶ added in v1.9.0
func (GenericIO) ReadMemoHeader ¶ added in v1.9.0
func (GenericIO) ReadNullFlag ¶ added in v1.9.0
func (GenericIO) WriteColumns ¶ added in v1.9.0
func (GenericIO) WriteHeader ¶ added in v1.9.0
func (GenericIO) WriteMemoHeader ¶ added in v1.9.0
type Header ¶ added in v1.1.0
type Header struct { FileType byte // File type flag Year uint8 // Last update year (0-99) Month uint8 // Last update month Day uint8 // Last update day RowsCount uint32 // Number of rows in file FirstRow uint16 // Position of first data row RowLength uint16 // Length of one data row, including delete flag Reserved [16]byte // Reserved TableFlags byte // Table flags CodePage byte // Code page mark }
Containing DBF header information like dBase FileType, last change and rows count. https://docs.microsoft.com/en-us/previous-versions/visualstudio/foxpro/st4a0s68(v=vs.80)#table-header-record-structure
func (*Header) ColumnsCount ¶ added in v1.1.0
Returns the calculated number of columns from the header info alone (without the need to read the columninfo from the header). This is the fastest way to determine the number of rows in the file.
func (*Header) Modified ¶ added in v1.1.0
Parses the year, month and day to time.Time. The year is stored in decades (2 digits) and added to the base century (2000). Note: we assume the year is between 2000 and 2099 as default.
func (*Header) RecordsCount ¶ added in v1.3.0
Returns the amount of records in the table
type IO ¶ added in v1.9.0
type IO interface { OpenTable(config *Config) (*File, error) Close(file *File) error Create(file *File) error ReadHeader(file *File) error WriteHeader(file *File) error ReadColumns(file *File) ([]*Column, *Column, error) WriteColumns(file *File) error ReadMemoHeader(file *File) error WriteMemoHeader(file *File, size int) error ReadMemo(file *File, address []byte) ([]byte, bool, error) WriteMemo(file *File, raw []byte, text bool, length int) ([]byte, error) ReadNullFlag(file *File, position uint64, column *Column) (bool, bool, error) ReadRow(file *File, position uint32) ([]byte, error) WriteRow(file *File, row *Row) error Search(file *File, field *Field, exactMatch bool) ([]*Row, error) GoTo(file *File, row uint32) error Skip(file *File, offset int64) Deleted(file *File) (bool, error) }
IO is the interface to work with the DBF file. Three implementations are available: - WindowsIO (for direct file access with Windows) - UnixIO (for direct file access with Unix) - GenericIO (for any custom file access implementing io.ReadWriteSeeker)
type MemoHeader ¶
type MemoHeader struct { NextFree uint32 // Location of next free block Unused [2]byte // Unused BlockSize uint16 // Block size (bytes per block) }
The raw header of the Memo file.
type Modification ¶ added in v1.3.0
type Modification struct { TrimSpaces bool // Trim spaces from string values Convert func(interface{}) (interface{}, error) // Conversion function to convert the value ExternalKey string // External key to use for the column }
Modification allows to change the column name or value type of a column when reading the table The TrimSpaces option is only used for a specific column, if the general TrimSpaces option in the config is false.
type Row ¶
type Row struct { Position uint32 // Position of the row in the file ByteOffset int64 // Byte offset of the row in the file Deleted bool // Deleted flag // contains filtered or unexported fields }
Row is a struct containing the row Position, deleted flag and data fields
func (*Row) BoolValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as a bool If the value is not a bool, an error is returned
func (*Row) BytesValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as a []byte If the value is not a []byte, []uint8 or string, an error is returned
func (*Row) FieldByName ¶ added in v1.5.0
Returns the field of a row by name or nil if not found
func (*Row) FloatValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as a float64 If the value is not castable to a float64, an error is returned
func (*Row) Increment ¶ added in v1.8.1
Increment increases set the value of the auto increment Column to the Next value Also increases the Next value by the amount of Step Rewrites the columns header
func (*Row) IntValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as an int64 If the value is not castable to an int64, an error is returned
func (*Row) MustBoolValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as a bool MustBoolValueByName panics if the value is not found or not a bool
func (*Row) MustBytesValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as a []byte MustBytesValueByName panics if the value is not found or not a []byte
func (*Row) MustFloatValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as a float64 MustFloatValueByName panics if the value is not found or not a float64
func (*Row) MustIntValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as an int32 MustIntValueByName panics if the value is not found or not an int32
func (*Row) MustStringValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as a string MustStringValueByName panics if the value is not found or not a string
func (*Row) MustTimeValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as a time.Time MustTimeValueByName panics if the value is not found or not a time.Time
func (*Row) MustValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name MustValueByName panics if the value is not found
func (*Row) StringValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as a string If the value is neither a string nor a byte slice, an error is returned
func (*Row) TimeValueByName ¶ added in v1.11.2
Returns the value of a row at the given column name as a time.Time If the value is not a time.Time, an error is returned
func (*Row) ToStruct ¶
Converts a row to a struct. The struct must have the same field names as the columns in the table or the dbase tag must be set. dbase tags can be used to name the field. For example: `dbase:"<table_name>.<field_name>"` or `dbase:"<field_name>"`
func (*Row) ValueByName ¶ added in v1.5.4
Returns the value of a row at the given column name
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a struct containing the table columns, modifications and the row pointer
type TableFlag ¶ added in v1.5.3
type TableFlag byte
Table flags inidicate the type of the table https://learn.microsoft.com/en-us/previous-versions/visualstudio/foxpro/st4a0s68(v=vs.71)
type UnixIO ¶ added in v1.9.0
type UnixIO struct{}
UnixIO implements the IO interface for unix systems.
var DefaultIO UnixIO