CloudSqlConfig#

pydantic model safir.database.CloudSqlConfig#

Configuration for a Cloud SQL database.

Parameters:
  • type (Literal['cloudsql'])

  • isolationLevel (str | None, default: None)

  • maxOverflow (int | None, default: None)

  • poolPrePing (bool | None, default: None)

  • poolRecycle (int | None, default: None)

  • poolSize (int | None, default: None)

  • poolTimeout (int | None, default: None)

  • project (str)

  • region (str)

  • instance (str)

  • database (str)

  • serviceAccount (str)

Config:
  • alias_generator: AliasGenerator = AliasGenerator(alias=None, validation_alias=<function to_camel at 0x7975e176a4b0>, serialization_alias=None)

  • extra: str = forbid

  • validate_by_name: bool = True

Fields:
Validators:
  • _remove_none » all fields

field database: Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Database name', description='Name of the database')] [Required]#

Name of the database

Validated by:
  • _remove_none

field instance: Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Instance', description='Cloud SQL instance name')] [Required]#

Cloud SQL instance name

Validated by:
  • _remove_none

field isolation_level: Annotated[str | None, Field(title='Isolation level', description='Non-default isolation level for the database engine if specified')] = None#

Non-default isolation level for the database engine if specified

Validated by:
  • _remove_none

field max_overflow: Annotated[int | None, Field(title='Surge connections', description='Maximum number of connections over the pool size for surge traffic')] = None#

Maximum number of connections over the pool size for surge traffic

Validated by:
  • _remove_none

field pool_pre_ping: Annotated[bool | None, Field(title='Check connections', description='Check that a connection is alive before returning it to a session')] = None#

Check that a connection is alive before returning it to a session

Validated by:
  • _remove_none

field pool_recycle: Annotated[int | None, Field(title='Recycle lifetime', description='Discard any idle connection open for longer than the provided number of seconds rather than attempting to reuse it. If the connection idle timeout on the database server is known, setting this to slightly less than that timeout will produce the best results.')] = None#

Discard any idle connection open for longer than the provided number of seconds rather than attempting to reuse it. If the connection idle timeout on the database server is known, setting this to slightly less than that timeout will produce the best results.

Validated by:
  • _remove_none

field pool_size: Annotated[int | None, Field(title='Pool size', description='Connection pool size')] = None#

Connection pool size

Validated by:
  • _remove_none

field pool_timeout: Annotated[int | None, Field(title='Pool timeout', description='How long to wait for a connection from the connection pool before giving up.')] = None#

How long to wait for a connection from the connection pool before giving up.

Validated by:
  • _remove_none

field project: Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Project', description='Google Cloud Platform project of Cloud SQL instance')] [Required]#

Google Cloud Platform project of Cloud SQL instance

Validated by:
  • _remove_none

field region: Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Region', description='Region of the Cloud SQL instance')] [Required]#

Region of the Cloud SQL instance

Validated by:
  • _remove_none

field service_account: Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Service account', description='Google service account to use for authentication. This must be mapped to a Kubernetes service account through workload identity and be available as the default credentials. This service account must have the cloudsql.client and cloudsql.instanceUser roles.')] [Required]#

Google service account to use for authentication. This must be mapped to a Kubernetes service account through workload identity and be available as the default credentials. This service account must have the cloudsql.client and cloudsql.instanceUser roles.

Validated by:
  • _remove_none

field type: Literal['cloudsql'] [Required]#
Validated by:
  • _remove_none

engine_kwargs()#

Construct the keyword arguments to SQLAlchemy engine creation.

Return type:

dict[str, Any]

property instance_connection_name: str#

Instance connection name used for connecting to Cloud SQL.

property mock_url: str#

URL for mock connections.

property user: str#

Database user to connect as.

This must match the Google service account name except that for PostgreSQL databases, such as the one Gafaelfawr users, the trailing .gserviceaccount.com must be removed.