parameters

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package parameters parses through parameters to generate data for a DB table

the parameters package uses templates, either a default or a user defined template, to parse and generate data for a given database table

Index

Constants

View Source
const (
	RANDOM = iota + 1
	STATIC
	SEQ
	UUID
	REGEX
	EMAIL
	FIRSTNAME
	LASTNAME
	FULLNAME
	PHONE
	COUNTRY
	ADDRESS
	ZIPCODE
	CITY
	NULL
	NOW
)

ENUMS that will be used to generate SQL strings

View Source
const DEFAULTBOOLCODE = RANDOM

default code for the boolean parser

View Source
const DEFAULTDATECODE = NOW

default code for the date parser

View Source
const DEFAULTDATERANGE = "2001-01-01,2024-12-31"

default date range for the RANDOM code of the date parser

View Source
const DEFAULTEXPR = "[a-zA-Z]{10}"

default value for the REGEX code for the varchar parser

View Source
const DEFAULTFLOATCODE = RANDOM

default code for the integer parser

View Source
const DEFAULTFLOATRANGE = "0, 100"

default range for the RANGE code of the integer parser

View Source
const DEFAULTFLOATSTATIC = "0.0"

default value for the STATIC code of the integer parser

View Source
const DEFAULTINTCODE = SEQ

default code for the integer parser

View Source
const DEFAULTRANGE = "0,100"

default range for the RANGE code of the integer parser

View Source
const DEFAULTSTATIC = "0"

default value for the STATIC code of the integer parser

View Source
const DEFAULTUUIDCODE = UUID

default code for the UUID parser

View Source
const DEFAULVARCHARCODE = REGEX

default code for the varchar parser

Variables

This section is empty.

Functions

This section is empty.

Types

type BooleanColumnParser

type BooleanColumnParser struct {
}

BooleanColumnParser is the struct responsible for processing parameters and creating queries for the Boolean type columns

func (*BooleanColumnParser) ParseColumn

func (p *BooleanColumnParser) ParseColumn(col column) (string, error)

ParseColumn takes in a column and processes it in order to return a string value along with any errors that occur

type ColumnParser

type ColumnParser interface {
	ParseColumn(col column) (string, error)
}

ColumnParser is an interface that contains the ParseColumn function which is defined by all other parsers

type DateColumnParser

type DateColumnParser struct {
}

DateColumnParser is the struct responsible for processing parameters and creating queries for the Date type columns

func (*DateColumnParser) ParseColumn

func (p *DateColumnParser) ParseColumn(col column) (string, error)

ParseColumn takes in a column and processes it in order to return a string value along with any errors that occur

type FloatColumnParser

type FloatColumnParser struct {
	// contains filtered or unexported fields
}

FloatColumnParser is the struct responsible for processing parameters and creating queries for Integer type columns

func (*FloatColumnParser) ParseColumn

func (p *FloatColumnParser) ParseColumn(col column) (string, error)

ParseColumn takes in a column and processes it in order to return a string value along with any errors that occur

type IntColumnParser

type IntColumnParser struct {
	// contains filtered or unexported fields
}

IntColumnParser is the struct responsible for processing parameters and creating queries for Integer type columns

func (*IntColumnParser) ParseColumn

func (p *IntColumnParser) ParseColumn(col column) (string, error)

ParseColumn takes in a column and processes it in order to return a string value along with any errors that occur

type QueryWriter

type QueryWriter struct {
	TableOrder []string // queue
	// contains filtered or unexported fields
}

QueryWriter is the struct responsible for generating data for it's given table

func NewQueryWriter

func NewQueryWriter(db *sql.DB, tableName string) (*QueryWriter, error)

NewQueryWriter takes in a database connection alongside a table name and returns a pointer to a QueryWriter that is initialized and any errors that occurred

func NewQueryWriterWithTemplate

func NewQueryWriterWithTemplate(db *sql.DB, tableName string, filePath string) (*QueryWriter, error)

NewQueryWriterWithTemplate takes in a database connection, table name as well as a file path to a template that is used to set the values in the QueryWriter before returning a pointer to the initialized QueryWriter as well as any errors that occurred

func (*QueryWriter) ChangeTableToWriteFor

func (qw *QueryWriter) ChangeTableToWriteFor(tableName string) error

ChangeTableToWriteFor takes in a new table name and re-inits the QueryWriter. It returns any errors that happen upon re-initialization

func (*QueryWriter) GenerateEntries

func (qw *QueryWriter) GenerateEntries(amount int) ([]string, []string)

GenerateEntries takes in a number and generates that amount of entries in the form of INSERT and DELETE queries which it returns as a string array

func (*QueryWriter) GenerateEntry

func (qw *QueryWriter) GenerateEntry() ([]string, []string)

GenerateEntry is a wrapper around the GenerateEntries function that simply gives the later an amount of 1

func (*QueryWriter) Init

func (qw *QueryWriter) Init() error

Init initializes the QueryWriter and returns any errors that occur upon initialization

type UUIDColumnParser

type UUIDColumnParser struct {
}

UUIDColumnParser is the struct responsible for processing parameters and creating queries for the 'UUID' type columns

func (*UUIDColumnParser) ParseColumn

func (p *UUIDColumnParser) ParseColumn(col column) (string, error)

ParseColumn takes in a column and processes it in order to return a string value along with any errors that occur

type VarcharColumnParser

type VarcharColumnParser struct {
}

VarcharColumnParser is the struct responsible for processing parameters and creating queries for Varchar type columns

func (*VarcharColumnParser) ParseColumn

func (p *VarcharColumnParser) ParseColumn(col column) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL