Skip to content

Commit f9d9ac1

Browse files
committed
Validate connection before enter the main loop
1 parent 40a5ddd commit f9d9ac1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

dev_server/cloudsql.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ def do_desc(self, args):
9191
def do_load(self, args):
9292
self.do_run(args)
9393

94+
def preloop(self, *args, **kwargs):
95+
sqlcmd.SQLCmd.preloop(self, *args, **kwargs)
96+
# Just exit if the connect failed
97+
if self._SQLCmd__db is None: sys.exit(1)
98+
9499
def __init__(self, *args, **kwargs):
95100
sqlcmd.SQLCmd.__init__(self, *args, **kwargs)
96101
self.prompt = sqlcmd.SQLCmd.MAIN_PROMPT

0 commit comments

Comments
 (0)