Skip to content

Commit 848892a

Browse files
Tolerate pgspecial not installed
1 parent 1c58773 commit 848892a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/sql/run.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import sqlalchemy
88
import sqlparse
99
import prettytable
10-
from pgspecial.main import PGSpecial
10+
try:
11+
from pgspecial.main import PGSpecial
12+
except ImportError:
13+
PGSpecial = None
1114
from .column_guesser import ColumnGuesserMixin
1215

1316

@@ -295,6 +298,8 @@ def run(conn, sql, config, user_namespace):
295298
if first_word == 'begin':
296299
raise Exception("ipython_sql does not support transactions")
297300
if first_word.startswith('\\') and 'postgres' in str(conn.dialect):
301+
if not PGSpecial:
302+
raise ImportError('pgspecial not installed')
298303
pgspecial = PGSpecial()
299304
_, cur, headers, _ = pgspecial.execute(
300305
conn.session.connection.cursor(),

0 commit comments

Comments
 (0)