Returns the version of Postgres being run.
(self)
| 397 | return float(f"{major}.{minor}") |
| 398 | |
| 399 | async def get_version(self) -> float: |
| 400 | """ |
| 401 | Returns the version of Postgres being run. |
| 402 | """ |
| 403 | try: |
| 404 | response: Sequence[dict] = await self._run_in_new_connection( |
| 405 | "SHOW server_version" |
| 406 | ) |
| 407 | except ConnectionRefusedError as exception: |
| 408 | # Suppressing the exception, otherwise importing piccolo_conf.py |
| 409 | # containing an engine will raise an ImportError. |
| 410 | colored_warning(f"Unable to connect to database - {exception}") |
| 411 | return 0.0 |
| 412 | else: |
| 413 | version_string = response[0]["server_version"] |
| 414 | return self._parse_raw_version_string( |
| 415 | version_string=version_string |
| 416 | ) |
| 417 | |
| 418 | def get_version_sync(self) -> float: |
| 419 | return run_sync(self.get_version()) |
no test coverage detected