MCPcopy
hub / github.com/autobrr/qui / countSQLiteRows

Function countSQLiteRows

internal/database/sqlite_to_postgres.go:508–518  ·  view source on GitHub ↗
(ctx context.Context, db *sql.DB, tables []string)

Source from the content-addressed store, hash-verified

506}
507
508func countSQLiteRows(ctx context.Context, db *sql.DB, tables []string) (map[string]int64, error) {
509 counts := make(map[string]int64, len(tables))
510 for _, table := range tables {
511 var count int64
512 if err := db.QueryRowContext(ctx, "SELECT COUNT(*) FROM "+quoteIdent(table)).Scan(&count); err != nil {
513 return nil, fmt.Errorf("count sqlite rows for %s: %w", table, err)
514 }
515 counts[table] = count
516 }
517 return counts, nil
518}
519
520func listPostgresTables(ctx context.Context, pool *pgxpool.Pool) (map[string]struct{}, error) {
521 rows, err := pool.Query(ctx, `

Callers 1

MigrateSQLiteToPostgresFunction · 0.85

Calls 3

quoteIdentFunction · 0.85
ScanMethod · 0.80
QueryRowContextMethod · 0.65

Tested by

no test coverage detected