load

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service represents service used to

func New

func New(ctx context.Context, db *sql.DB, tableName string) (*Service, error)

New creates instance of Service

func (*Service) Exec

func (s *Service) Exec(ctx context.Context, any interface{}, options ...option.Option) (int, error)

Exec executes load statement specific for database

Example
package main

import (
	"context"
	"database/sql"
	"fmt"
	"github.com/viant/sqlx/io/load"
	"log"

	_ "github.com/viant/sqlx/metadata/product/mysql/load"
)

func main() {
	type Foo struct {
		ID   int
		Name string
	}
	dsn := ""
	db, err := sql.Open("mysql", dsn)
	if err != nil {
		log.Fatalln(err)
	}
	loader, err := load.New(context.Background(), db, "dest_table")
	if err != nil {
		log.Fatalln(err)
	}
	var data []Foo

	//data = getAppData()
	count, err := loader.Exec(context.TODO(), &data)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Printf("loaded %v\n", count)
}
Output:

Directories

Path Synopsis
reader
csv

Jump to

Keyboard shortcuts

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