Issues a "USE " command where is the current database. It is typically needed after the connection is (re-)established to the Impala daemon. If immediately is False, it appends the USE command to self.cmdqueue. If immediately is True, it executes the USE command right away.
(self, immediately=False)
| 1209 | self._validate_database() |
| 1210 | |
| 1211 | def _validate_database(self, immediately=False): |
| 1212 | """ Issues a "USE <db>" command where <db> is the current database. |
| 1213 | It is typically needed after the connection is (re-)established to the Impala daemon. |
| 1214 | |
| 1215 | If immediately is False, it appends the USE command to self.cmdqueue. |
| 1216 | If immediately is True, it executes the USE command right away. |
| 1217 | """ |
| 1218 | if not self.imp_client.connected: |
| 1219 | return |
| 1220 | # Should only check if successfully connected. |
| 1221 | if self.current_db: |
| 1222 | self.current_db = self.current_db.strip('`') |
| 1223 | use_current_db = ('use `%s`' % self.current_db) |
| 1224 | if immediately: |
| 1225 | self.onecmd(use_current_db) |
| 1226 | else: |
| 1227 | self.cmdqueue.append(use_current_db + ImpalaShell.CMD_DELIM) |
| 1228 | |
| 1229 | def _print_if_verbose(self, message, file_descriptor=sys.stderr, flush=True): |
| 1230 | if self.verbose: |
no test coverage detected