Skip to content

Commit 4593332

Browse files
authored
PostgresLookup: add graceful import handling (#959)
1 parent 7b4d744 commit 4593332

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

quixstreams/dataframe/joins/lookups/postgresql.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@
77
from collections import OrderedDict
88
from typing import Any, Literal, Mapping, Tuple, Union
99

10-
import psycopg2
11-
from psycopg2 import sql
12-
from psycopg2.extensions import cursor as pg_cursor
10+
try:
11+
import psycopg2
12+
from psycopg2 import sql
13+
from psycopg2.extensions import cursor as pg_cursor
14+
except ImportError as exc:
15+
raise ImportError(
16+
f"Package `{exc.name}` is missing: "
17+
'run "pip install quixstreams[postgresql]" to fix it'
18+
) from exc
1319

1420
from .base import BaseField, BaseLookup
1521
from .utils import CacheInfo

0 commit comments

Comments
 (0)