File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ class Batch:
1515class Engine (metaclass = ABCMeta ):
1616 def __init__ (self ):
1717 self .check_version ()
18- self .tables = []
1918
2019 @property
2120 @abstractmethod
Original file line number Diff line number Diff line change 1616from piccolo .query .base import Query
1717from piccolo .querystring import QueryString
1818from piccolo .utils .sync import run_sync
19+ from piccolo .utils .warnings import colored_warning
1920
2021
2122@dataclass
@@ -220,12 +221,19 @@ def get_version(self) -> float:
220221 self ._run_in_new_connection ("SHOW server_version" ),
221222 )
222223
223- response : t .Sequence [t .Dict ] = future .result ()
224-
225- server_version = response [0 ]["server_version" ]
226- major , minor , _ = server_version .split ("." )
227- version = float (f"{ major } .{ minor } " )
228- return version
224+ try :
225+ response : t .Sequence [t .Dict ] = future .result ()
226+ except ConnectionRefusedError as exception :
227+ # Suppressing the exception, otherwise importing piccolo_conf.py
228+ # containing an engine will raise an ImportError.
229+ colored_warning ("Unable to connect to database" )
230+ print (exception )
231+ return 0.0
232+ else :
233+ server_version = response [0 ]["server_version" ]
234+ major , minor , _ = server_version .split ("." )
235+ version = float (f"{ major } .{ minor } " )
236+ return version
229237
230238 ###########################################################################
231239
You can’t perform that action at this time.
0 commit comments