feat: enhance column type querying functions for improved error handling and SQL compatibility

This commit is contained in:
2026-04-04 10:17:20 -05:00
parent 46c08323ad
commit de0d4a5516
2 changed files with 104 additions and 29 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"context"
"database/sql"
"errors"
"fmt"
"sync"
"time"
@@ -51,25 +52,25 @@ func connectToDatabases() (*sql.DB, *pgxpool.Pool, error) {
var sourceDb *sql.DB
var targetDb *pgxpool.Pool
var wg sync.WaitGroup
wg.Go(func() {
sourceDb, sourceDbErr = connectToSqlServer()
if sourceDbErr != nil {
log.Error("Unable to connect to source db: ", sourceDbErr)
}
sourceDb, sourceDbErr = connectToSqlServer()
if sourceDbErr != nil {
log.Error("Unable to connect to source db: ", sourceDbErr)
}
})
wg.Go(func() {
targetDb, targetDbErr = connectToPostgres()
if targetDbErr != nil {
log.Error("Unable to connect to target db: ", targetDbErr)
}
targetDb, targetDbErr = connectToPostgres()
if targetDbErr != nil {
log.Error("Unable to connect to target db: ", targetDbErr)
}
})
wg.Wait()
if sourceDbErr != nil || targetDbErr != nil {
return nil, nil, fmt.Errorf("Unable to connect to databases: %w (source), %w (target)", sourceDbErr, targetDbErr)
return nil, nil, errors.New("Unable to connect to databases")
}
return sourceDb, targetDb, nil