Skip to content

Commit 70ca9da

Browse files
committed
fix: Psycopg2
1 parent 75b2443 commit 70ca9da

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/charms/data_platform_libs/v1/data_interfaces.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ def _on_database_requested(self, event: DatabaseRequestedEvent) -> None:
287287
from typing_extensions import TypeAliasType, override
288288

289289
try:
290-
import psycopg
290+
import psycopg2
291291
except ImportError:
292-
psycopg = None
292+
psycopg2 = None
293293

294294
# The unique Charmhub library identifier, never change it
295295
LIBID = "6c3e6b6680d64e9c89e611d1a15f65be"
@@ -2488,17 +2488,17 @@ def are_all_resources_created(self, rel_id: int) -> bool:
24882488
def _is_pg_plugin_enabled(plugin: str, connection_string: str) -> bool:
24892489
# Actual checking method.
24902490
# No need to check for psycopg here, it's been checked before.
2491-
if not psycopg:
2491+
if not psycopg2:
24922492
return False
24932493

24942494
try:
2495-
with psycopg.connect(connection_string) as connection:
2495+
with psycopg2.connect(connection_string) as connection:
24962496
with connection.cursor() as cursor:
24972497
cursor.execute(
24982498
"SELECT TRUE FROM pg_extension WHERE extname=%s::text;", (plugin,)
24992499
)
25002500
return cursor.fetchone() is not None
2501-
except psycopg.Error as e:
2501+
except psycopg2.Error as e:
25022502
logger.exception(
25032503
f"failed to check whether {plugin} plugin is enabled in the database: %s",
25042504
str(e),
@@ -2512,7 +2512,7 @@ def is_postgresql_plugin_enabled(self, plugin: str, relation_id: int = 0) -> boo
25122512
plugin: name of the plugin to check.
25132513
relation_id: Optional index to check the database (default: 0 - first relation).
25142514
"""
2515-
if not psycopg:
2515+
if not psycopg2:
25162516
return False
25172517

25182518
# Can't check a non existing relation.

tests/v1/integration/database-charm/.charmcraft_output_packages.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)