Mountaineer & FastAPI

Iceaxe includes some helper classes that make it easier to connect to databases from within dependency-injection frameworks (like Mountaineer & FastAPI).

Config

CLASSiceaxe.mountaineer.config.DatabaseConfig

Configuration settings for PostgreSQL database connection. This class uses Pydantic's BaseSettings to manage environment-based configuration.

Class Attributes

  • Name
    POSTGRES_HOST
    Type
    str
    Description

    The hostname where the PostgreSQL server is running. This can be a domain name or IP address (e.g., 'localhost' or '127.0.0.1').

  • Name
    POSTGRES_USER
    Type
    str
    Description

    The username to authenticate with the PostgreSQL server. This user should have appropriate permissions for the database operations.

  • Name
    POSTGRES_PASSWORD
    Type
    str
    Description

    The password for authenticating the PostgreSQL user. This should be kept secure and not exposed in code or version control.

  • Name
    POSTGRES_DB
    Type
    str
    Description

    The name of the PostgreSQL database to connect to. This database should exist on the server before attempting connection.

  • Name
    POSTGRES_PORT
    Type
    int
    Description

    The port number where PostgreSQL server is listening. Defaults to the standard PostgreSQL port 5432 if not specified.

  • Name
    ICEAXE_UNCOMMITTED_VERBOSITY
    Type
    MODIFICATION_TRACKER_VERBOSITY | None
    Description

    The verbosity level for uncommitted modifications. If set to None, uncommitted modifications will not be tracked.


Dependencies

FUNCTIONiceaxe.mountaineer.dependencies.core.get_db_connection

get_db_connection

A dependency that provides a database connection for use in FastAPI endpoints or other dependency-injected contexts. The connection is automatically closed when the endpoint finishes processing.

This dependency:

  • Creates a new PostgreSQL connection using the provided configuration
  • Wraps it in a DBConnection for ORM functionality
  • Automatically closes the connection when done
  • Integrates with Mountaineer's dependency injection system

Parameters

  • Name
    config
    Type
    DatabaseConfig
    Description

    Default: Depends(CoreDependencies.get_config_with_type(DatabaseConfig))

    DatabaseConfig instance containing connection parameters. Automatically injected by Mountaineer if not provided.


CLI

FUNCTIONiceaxe.mountaineer.cli.generate_migration

generate_migration

Parameters

  • Name
    message
    Type
    str | None
    Description

    Default: None


FUNCTIONiceaxe.mountaineer.cli.apply_migration

apply_migration


FUNCTIONiceaxe.mountaineer.cli.rollback_migration

rollback_migration