SqlServerConnection

SQLServer connection using the official driver.

Implements: IReferenceable, IConfigurable, IOpenable

Description

The SqlServerConnection class allows you to create a connection to an SQLServer database using the official driver.

Important points

  • By defining a connection and sharing it through multiple persistence components you can reduce number of used database connections.

Configuration parameters

connection(s):

  • discovery_key: (optional) key to retrieve the connection from IDiscovery
  • host: host name or IP address
  • port: port number (default: 27017)
  • uri: resource URI or connection string with all parameters in it

credential(s):

  • store_key: (optional) key to retrieve the credentials from ICredentialStore
  • username: username
  • password: user’s password

options:

  • connect_timeout: (optional) number of milliseconds to wait before timing out when connecting a new client (default: 0)
  • idle_timeout: (optional) number of milliseconds a client must sit idle in the pool and not be checked out (default: 10000)
  • max_pool_size: (optional) maximum number of clients the pool should contain (default: 10)

References

  • *:logger:*:*:1.0 - (optional) ILogger components to pass log messages
  • *:discovery:*:*:1.0 - (optional) IDiscovery services
  • *:credential-store:*:*:1.0 (optional) credential stores to resolve credentials

Fields

_connection

The SQLServer connection pool object.

_connection: Any

_connection_resolver

The connection resolver.

_connection_resolver: SqlServerConnectionResolver

_database_name

The SQLServer database name.

_database_name: str

_logger

The logger.

_logger: CompositeLogger

_options

The configuration options.

_options: ConfigParams

Instance methods

close

Closes a component and frees used resources.

close(correlation_id: Optional[str])

  • correlation_id: Optional[str] - (optional) transaction id used to trace execution through the call chain.

configure

Configures a component by passing configuration parameters.

configure(config: ConfigParams)

  • config: ConfigParams - configuration parameters to be set.

get_connection

Gets the connection to an SQLServer database.

get_connection(): connection

  • returns: Any - connection to an SQLServer database.

get_database_name

Gets the name of an SQLServer database.

get_database_name(): str

  • returns: str - database name.