photum/backend/cmd/debug_list_mg/main.go

33 lines
753 B
Go

package main
import (
"context"
"fmt"
"os"
"github.com/jackc/pgx/v5"
)
func main() {
dbURL := "postgres://user:pass@localhost:54322/photum-v2?sslmode=disable"
conn, err := pgx.Connect(context.Background(), dbURL)
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to connect: %v\n", err)
os.Exit(1)
}
defer conn.Close(context.Background())
rows, err := conn.Query(context.Background(), "SELECT id, ano_semestre FROM anos_formaturas WHERE regiao = 'MG' ORDER BY ano_semestre")
if err != nil {
fmt.Fprintf(os.Stderr, "Query failed: %v\n", err)
os.Exit(1)
}
defer rows.Close()
fmt.Println("--- ANOS FORMATURAS (MG) ---")
for rows.Next() {
var id, ano string
rows.Scan(&id, &ano)
fmt.Printf("ID: %s | Ano: %q\n", id, ano)
}
}