get db instance
(c plugin.SubTaskContext)
| 461 | |
| 462 | // get db instance |
| 463 | func 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 |
| 484 | func getExportingTables(c plugin.SubTaskContext, db dal.Dal) (starrocksTables []string, err error) { |
no test coverage detected