Skip to content

Commit 9da0d4b

Browse files
authored
Make pymysql optional. (#11)
Doesn't change the setup.py, because I generally want to install it, but for special purposes...
1 parent 51e10be commit 9da0d4b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

partitionmanager/sql.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
import subprocess
88
import xml.parsers.expat
99

10-
import pymysql
11-
import pymysql.cursors
12-
1310
import partitionmanager.types
1411

1512

@@ -151,6 +148,13 @@ class IntegratedDatabaseCommand(partitionmanager.types.DatabaseCommand):
151148
"""
152149

153150
def __init__(self, url):
151+
try:
152+
import pymysql
153+
import pymysql.cursors
154+
except ModuleNotFoundError as mnfe:
155+
logging.fatal("You cannot use --dburl without the pymysql package.")
156+
raise mnfe
157+
154158
self.db = None
155159
if url.path and url.path != "/":
156160
self.db = url.path.lstrip("/")

0 commit comments

Comments
 (0)