MCPcopy
hub / github.com/apache/devlake / getDbInstance

Function getDbInstance

backend/plugins/starrocks/tasks/tasks.go:463–481  ·  view source on GitHub ↗

get db instance

(c plugin.SubTaskContext)

Source from the content-addressed store, hash-verified

461
462// get db instance
463func getDbInstance(c plugin.SubTaskContext) (o *gorm.DB, err error) {
464 config := c.GetData().(*StarRocksConfig)
465 switch config.SourceType {
466 case "mysql":
467 o, err = gorm.Open(mysql.Open(config.SourceDsn))
468 if err != nil {
469 return nil, err
470 }
471 case "postgres":
472 o, err = gorm.Open(postgres.Open(config.SourceDsn))
473 if err != nil {
474 return nil, err
475 }
476 default:
477 return nil, errors.NotFound.New(fmt.Sprintf("unsupported source type %s", config.SourceType))
478 }
479
480 return o, nil
481}
482
483// get imported tables
484func getExportingTables(c plugin.SubTaskContext, db dal.Dal) (starrocksTables []string, err error) {

Callers 1

ExportDataFunction · 0.85

Calls 2

GetDataMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected