# get_connection()


Obtain a connection from the pool.


Usage


``` python
get_connection(
    backend="postgresql",
    host="localhost",
    port=5432,
)
```


If a pool for the given `(backend, host, port)` triple already exists, a connection is drawn from it. Otherwise a new pool is created with [MIN_CONNECTIONS](MIN_CONNECTIONS.md#gdtest_complete_docstrings.MIN_CONNECTIONS) warm connections.


## Parameters


`backend: BackendName = ``"postgresql"`  
Which database backend to connect to.

`host: str = ``"localhost"`  
The server hostname or IP address.

`port: int = ``5432`  
The server port number.


## Returns


`Connection`  
A ready-to-use connection.


## Raises


`ConnectionPoolExhausted`  
If the pool has reached [MAX_CONNECTIONS](MAX_CONNECTIONS.md#gdtest_complete_docstrings.MAX_CONNECTIONS).

`TimeoutError`  
If a connection cannot be established within [timeout](timeout.md#gdtest_complete_docstrings.timeout) seconds.


## See Also

[Connection](Connection.md#gdtest_complete_docstrings.Connection)  

[MAX_CONNECTIONS](MAX_CONNECTIONS.md#gdtest_complete_docstrings.MAX_CONNECTIONS)  

[timeout](timeout.md#gdtest_complete_docstrings.timeout)
