Documentation ¶
Index ¶
- type Service
- func (s *Service) DetectProduct(ctx context.Context, db *sql.DB) (*database.Product, error)
- func (s *Service) Execute(ctx context.Context, db *sql.DB, kind info.Kind, options ...option.Option) (sql.Result, error)
- func (s *Service) Info(ctx context.Context, db *sql.DB, kind info.Kind, sink Sink, ...) error
- type Sink
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 metadata service
func (*Service) DetectProduct ¶
DetectProduct detect product for supplied *sql.DB
func (*Service) Execute ¶
func (s *Service) Execute(ctx context.Context, db *sql.DB, kind info.Kind, options ...option.Option) (sql.Result, error)
Execute execute the metadata kind corresponding SQL
func (*Service) Info ¶
func (s *Service) Info(ctx context.Context, db *sql.DB, kind info.Kind, sink Sink, options ...option.Option) error
Info execute the metadata kind corresponding Query, result are passed to sink
Example ¶
package main import ( "context" "database/sql" "github.com/viant/sqlx/metadata" "github.com/viant/sqlx/metadata/info" "github.com/viant/sqlx/metadata/sink" "github.com/viant/sqlx/option" "log" ) func main() { dsn := "" driver := "" db, err := sql.Open(driver, dsn) if err != nil { log.Fatalln(err) } meta := metadata.New() { tables := []sink.Table{} catalog := "" schema := "mydb" err := meta.Info(context.TODO(), db, info.KindTables, &tables, option.NewArgs(catalog, schema)) if err != nil { log.Fatalln(err) } log.Println(tables) } { columnes := []sink.Column{} catalog := "" schema := "mydb" tables := "myTable" err := meta.Info(context.TODO(), db, info.KindTable, &columnes, option.NewArgs(catalog, schema, tables)) if err != nil { log.Fatalln(err) } log.Println(columnes) } }
Output:
Click to show internal directories.
Click to hide internal directories.