MCPcopy Create free account
hub / github.com/quentinhardy/odat / startInteractiveSQLShell

Method startInteractiveSQLShell

Search.py:152–183  ·  view source on GitHub ↗

Start an interactive SQL shell Return True when finished Tested with: - select - create user - create or replace

(self)

Source from the content-addressed store, hash-verified

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 '''

Callers 1

runSearchModuleFunction · 0.95

Calls 6

set_decoMethod · 0.95
add_rowsMethod · 0.95
drawMethod · 0.95
TexttableClass · 0.90
getScreenSizeFunction · 0.90
__execQuery__Method · 0.80

Tested by

no test coverage detected