MCPcopy Index your code
hub / github.com/InferCore/InferCore / NewPostgresStore

Function NewPostgresStore

internal/requests/postgres.go:57–68  ·  view source on GitHub ↗

NewPostgresStore opens a Postgres-backed ledger using lib/pq (connection string / DSN).

(dsn string)

Source from the content-addressed store, hash-verified

55
56// NewPostgresStore opens a Postgres-backed ledger using lib/pq (connection string / DSN).
57func NewPostgresStore(dsn string) (Store, error) {
58 db, err := sql.Open("postgres", dsn)
59 if err != nil {
60 return nil, err
61 }
62 db.SetMaxOpenConns(8)
63 if _, err := db.Exec(postgresSchema); err != nil {
64 _ = db.Close()
65 return nil, fmt.Errorf("postgres migrate: %w", err)
66 }
67 return &postgresStore{db: db}, nil
68}
69
70func (s *postgresStore) CreateRequest(ctx context.Context, row RequestRow) error {
71 _, err := s.db.ExecContext(ctx, `

Callers 1

NewFromConfigFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected