Start an interactive SQL shell Return True when finished Tested with: - select - create user - create or replace
(self)
| 150 | return False |
| 151 | |
| 152 | def startInteractiveSQLShell(self): |
| 153 | """ |
| 154 | Start an interactive SQL shell |
| 155 | Return True when finished |
| 156 | Tested with: |
| 157 | - select |
| 158 | - create user |
| 159 | - create or replace |
| 160 | """ |
| 161 | print("Ctrl-D to close the SQL shell") |
| 162 | while True: |
| 163 | theLine = None |
| 164 | allLines = "" |
| 165 | print("SQL> ", end='') |
| 166 | while theLine != "": |
| 167 | try: |
| 168 | theLine = input() |
| 169 | except EOFError: |
| 170 | print("\nSQL shell closed") |
| 171 | return True |
| 172 | allLines += theLine |
| 173 | if allLines != "": |
| 174 | results = self.__execQuery__(query=allLines, getColumnNames=True,stringOnly=True) |
| 175 | if isinstance(results,Exception): |
| 176 | print(results) |
| 177 | elif results==[()]: |
| 178 | print("Executed successfully") |
| 179 | else: |
| 180 | table = Texttable(max_width=getScreenSize()[0]) |
| 181 | table.set_deco(Texttable.HEADER) |
| 182 | table.add_rows(results) |
| 183 | print(table.draw()) |
| 184 | |
| 185 | def getAllPrivs(self): |
| 186 | ''' |
no test coverage detected