PostgreSQL

Provides an API for accessing PostgreSQL databases

Technology

The postgres module provides PostgreSQL database integration for Project Forge applications. This module extends the base database module with PostgreSQL-specific functionality, including advanced features, driver integration, and PostgreSQL-optimized performance.

Overview

This module adds PostgreSQL database support to Project Forge applications and requires the database module. It provides:

Key Features

PostgreSQL Compatibility

Advanced Data Types

Performance

Security

Configuration

Environment Variables

The module reads configuration from environment variables (with optional prefix):

Usage

Basic Setup

1
2
3
4
5
6
7
8
9
// Load configuration from environment
params := PostgresParamsFromEnv("")

// Open database connection
db, err := database.OpenPostgresDatabase(params)
if err != nil {
return err
}
defer db.Close()

Custom Configuration

 1
2
3
4
5
6
7
8
9
10
11
12
13
// Manual configuration
params := &PostgresParams{
Host: "postgres.example.com",
Port: 5432,
User: "app_user",
Password: "secure_password",
Database: "app_database",
Schema: "app_schema",
MaxConnections: 25,
Debug: false,
}

db, err := database.OpenPostgresDatabase(params)

With Environment Prefix

1
2
3
// Use custom environment variable prefix
// Reads myapp_db_host, myapp_db_port, etc.
params := PostgresParamsFromEnv("myapp_")

Dependencies

This module requires:

Production Considerations

Connection Pooling

Performance Tuning

Schema Management

Source Code

See Also