Documentation ¶
Overview ¶
Package database interacts with the MySQL 5.7 datastore of Defacto2.
Index ¶
- Constants
- Variables
- func Approve(verbose bool) error
- func CheckID(s string) error
- func CheckUUID(s string) error
- func ColumnTypes(table string) error
- func Connect() *sql.DB
- func ConnectErr() (db *sql.DB, err error)
- func ConnectInfo() string
- func DateTime(b sql.RawBytes) string
- func FileUpdate(name string, database time.Time) (bool, error)
- func Fix() error
- func IsID(s string) bool
- func IsNew(b []sql.RawBytes) bool
- func IsUUID(s string) bool
- func LastUpdate() (t time.Time, err error)
- func LookupFile(s string) (name string, err error)
- func LookupID(s string) (id uint, err error)
- func ObfuscateParam(param string) string
- func StripChars(s string) string
- func StripStart(s string) string
- func Tbls() string
- func Total(s *string) (sum int, err error)
- func TrimSP(s string) string
- type Connection
- type Empty
- type Flags
- type IDs
- type Method
- type Table
- type TableData
- type TablesData
- type TablesTmp
- type Update
Constants ¶
const Datetime = "2006-01-02T15:04:05Z"
Datetime MySQL 5.7 format.
const UpdateID = "b66dc282-a029-4e99-85db-2cf2892fffcc"
UpdateID is a user id to use with the updatedby column.
Variables ¶
var ( ErrColType = errors.New("the value type is not usable with the mysql column") ErrConnect = errors.New("could not connect to the mysql database server") ErrNoID = errors.New("unique id is does not exist in the database table") ErrSynID = errors.New("id is not a valid id or uuid value") ErrSynUUID = errors.New("id is not a valid uuid") ErrNoTable = errors.New("unknown database table") ErrNoMethod = errors.New("unknown database export type") )
Functions ¶
func CheckID ¶
CheckID reports an error message for an incorrect universal unique record id or MySQL auto-generated id.
func ColumnTypes ¶
ColumnTypes details the columns used by the table.
func ConnectErr ¶
ConnectErr will connect to the database or return any errors.
func ConnectInfo ¶
func ConnectInfo() string
ConnectInfo will connect to the database and return any errors.
func FileUpdate ¶
FileUpdate reports if the file is newer than the database time.
func LastUpdate ¶
LastUpdate reports the time when the files database was last modified.
func LookupFile ¶
LookupFile returns the filename from a supplied UUID or database ID value.
func ObfuscateParam ¶
ObfuscateParam hides the param value using the method implemented in CFWheels obfuscateParam() helper.
func StripChars ¶ added in v1.1.18
StripChars removes incompatible characters used for groups and author names.
func StripStart ¶ added in v1.1.18
StripStart removes non-alphanumeric characters from the start of the string.
Types ¶
type Connection ¶
type Connection struct { // Name of the database Name string // User name access. User string // Pass is the user password. Pass string // Server is URI to connect to the database, using the protocol, address and port. Server string // Protocol to connect to the database. Protocol string // Address to connect to the database. Address string // Port to connect to the database. Port string }
Connection information for a MySQL database.
func (*Connection) String ¶
func (c *Connection) String() string
type Empty ¶
type Empty struct{}
Empty is used as a blank value for search maps. See: https://dave.cheney.net/2014/03/25/the-empty-struct
type Flags ¶
type Flags struct { Compress bool // Compress and save the output CronJob bool // Parallel bool // Run --table=all queries in parallel Save bool // Save the output uncompressed Table Table // Table of the database to use Method Method // Method to export Tables string // --table flag result Type string // Type of export (create|update) Version string // df2 app version pass-through Limit uint // Limit the number of records }
Flags are command line arguments.
func (*Flags) ExportCronJob ¶
ExportCronJob is intended for an operating system time-based job scheduler. It creates both create and update types exports for the files table.
func (*Flags) ExportDB ¶
ExportDB saves or prints a MySQL 5.7 compatible SQL import database statement.
func (*Flags) ExportTable ¶
ExportTable saves or prints a MySQL 5.7 compatible SQL import table statement.
type IDs ¶
type IDs map[string]struct{}
IDs are unique UUID values used by the database and filenames.
type TableData ¶
type TableData struct { VER string CREATE string TABLE string INSERT string SQL string UPDATE string }
TableData is a container for the tableTmpl template.
type TablesData ¶
TablesData is a data container for the tablesTmpl template.
type TablesTmp ¶
type TablesTmp struct { VER string DB string CREATE []TablesData }
TablesTmp is a container for the tablesTmpl template.