Documentation ¶
Index ¶
- Constants
- func CreateTestTable(db *DB, name string, schema interface{}) error
- func Placeholder(driverName string, i int) string
- func SplitTableSchema(driver string, tablePath string) (schemaName string, tableName string)
- type ColumnInfo
- type DB
- type PGDumpReader
- type RowMap
- type SchemaTable
- type Stmt
- type TableInfo
- type TestRow
- type Tx
- type URL
Constants ¶
const ( ProtocolPostgres = "postgres" ProtocolMySQL = "mysql" ProtocolSnowflake = "snowflake" )
const (
SnowflakeComputingDomain = ".snowflakecomputing.com"
)
Variables ¶
This section is empty.
Functions ¶
func CreateTestTable ¶
CreateTestTable creates a test table at name in the database
func Placeholder ¶
Placeholder returns a placeholder for the given driver assuming i placeholders have been provided before it. It is 0 indexed in this way.
This means that the first Postgres placeholder is `$1` when i = 0. This is more ergonimic for contructing a list of arguments since i = len(args) but is perhaps unintuitive for those familiar with Postgres.
Types ¶
type ColumnInfo ¶
ColumnInfo is information about a single column in a SQL table
type DB ¶
DB is an alias for sqlx.DB which is the standard database type used throughout the project
type PGDumpReader ¶
type PGDumpReader struct { Header []byte // contains filtered or unexported fields }
PGDumpReader parses a pgdump file into a header, rows, and a footer
func NewPGDumpReader ¶
func NewPGDumpReader(r *bufio.Reader) *PGDumpReader
NewPGDumpReader creates a new PGDumpReader
func (*PGDumpReader) ReadRow ¶
func (r *PGDumpReader) ReadRow() ([]byte, error)
ReadRow parses the pgdump file and populates the header and the footer It returns EOF when done, and at that time both the Header and Footer will be populated. Both header and footer are required. If either are missing, an error is returned
type RowMap ¶
type RowMap = map[string]interface{}
RowMap is an alias for map[string]interface{} which is the type used by sqlx.MapScan()
type SchemaTable ¶
type SchemaTable struct { SchemaName string `json:"schemaname"` TableName string `json:"tablename"` }
SchemaTable stores a given table's name and schema.
func ListTables ¶
func ListTables(ctx context.Context, db *DB) ([]SchemaTable, error)
ListTables returns an array of SchemaTable structs that represent the tables.
type Stmt ¶
Stmt is an alias for sqlx.Stmt which is the standard prepared statement type used throught the project
type TableInfo ¶
type TableInfo struct { Driver string Name string Schema string Columns []ColumnInfo }
TableInfo contains information about a SQL table
func GetTableInfo ¶
GetTableInfo looks up information about the table using INFORMATION_SCHEMA
func GetTableInfoTx ¶
GetTableInfoTx looks up information about the table using INFORMATION_SCHEMA
func (*TableInfo) ColumnNames ¶
type TestRow ¶
type TestRow struct { Id int16 `column:"c_id" dtype:"SMALLINT" constraint:"PRIMARY KEY NOT NULL"` Smallint int16 `column:"c_smallint" dtype:"SMALLINT" constraint:"NOT NULL"` Int int32 `column:"c_int" dtype:"INT" constraint:"NOT NULL"` Bigint int64 `column:"c_bigint" dtype:"BIGINT" constraint:"NOT NULL"` Float float32 `column:"c_float" dtype:"FLOAT" constraint:"NOT NULL"` NumericInt int64 `column:"c_numeric_int" dtype:"NUMERIC(20,0)" constraint:"NOT NULL"` NumericFloat float64 `column:"c_numeric_float" dtype:"NUMERIC(20,19)" constraint:"NOT NULL"` Varchar string `column:"c_varchar" dtype:"VARCHAR(100)" constraint:"NOT NULL"` Time time.Time `column:"c_time" dtype:"TIMESTAMP" constraint:"NOT NULL"` SmallintNull sql.NullInt16 `column:"c_smallint_null" dtype:"SMALLINT" constraint:"NULL"` IntNull sql.NullInt32 `column:"c_int_null" dtype:"INT" constraint:"NULL"` BigintNull sql.NullInt64 `column:"c_bigint_null" dtype:"BIGINT" constraint:"NULL"` FloatNull sql.NullFloat64 `column:"c_float_null" dtype:"FLOAT" constraint:"NULL"` NumericIntNull sql.NullInt64 `column:"c_numeric_int_null" dtype:"NUMERIC(20,0)" constraint:"NULL"` NumericFloatNull sql.NullFloat64 `column:"c_numeric_float_null" dtype:"NUMERIC(20,19)" constraint:"NULL"` VarcharNull sql.NullString `column:"c_varchar_null" dtype:"VARCHAR(100)" constraint:"NULL"` TimeNull sql.NullTime `column:"c_time_null" dtype:"TIMESTAMP" constraint:"NULL"` }
TestRow is the type of a row in the test table struct tag: sql:"<column_name>,<data_type>,<table_constraint>"
type Tx ¶
Tx is an alias for sqlx.Tx which is the standard transaction type used throughout the project