Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if flowname == None:
parser.print_help()
sys.exit(1)
try:
f = open(flowname,'r')
except Exception, e:
exitwitherror("Error in opening SQL flow: " + str(e))
statement = f.readline()
if not statement:
sys.exit()
while True:
while not apsw.complete(statement):
line = f.readline()
statement += line
if not line:
if statement.rstrip('\r\n')!='':
sys.stderr.write("Incomplete query:"+statement)
f.close()
sys.exit()
try :
for row in Connection.cursor().execute(statement):
if len(row) > 1:
print(json.dumps(row, separators=(',',':'), ensure_ascii=False).encode('utf_8', 'replace'))
else:
print(unicode(row[0]).encode('utf_8', 'replace'))
statement = ''
except Exception, e:
exitwitherror("Error when executing query: \n"+statement+"\nThe error was: "+ str(e))
For dot commands it will be one line. For SQL statements it
will be as many as is necessary to have a
:meth:`~apsw.complete` statement (ie semicolon terminated).
Returns None on end of file."""
try:
self._completion_first=True
command=self.getline(self.prompt)
if command is None:
return None
if len(command.strip())==0:
return ""
if command[0]=="?":
command=".help "+command[1:]
# incomplete SQL?
while command[0]!="." and not apsw.complete(command):
self._completion_first=False
line=self.getline(self.moreprompt)
if line is None: # unexpected eof
raise self.Error("Incomplete SQL (line %d of %s): %s\n" % (self.input_line_number, getattr(self.stdin, "name", ""), command))
if line in ("go", "/"):
break
command=command+"\n"+line
return command
except KeyboardInterrupt:
self.handle_interrupt()
return ""
"""Returns a complete input.
For dot commands it will be one line. For SQL statements it
will be as many as is necessary to have a
:meth:`~apsw.complete` statement (ie semicolon terminated).
Returns None on end of file."""
try:
self._completion_first=True
command=self.getline(self.prompt)
if command is None:
return None
if len(command.strip())==0:
return ""
if command[0]=="?": command=".help "+command[1:]
# incomplete SQL?
while command[0]!="." and not apsw.complete(command):
self._completion_first=False
line=self.getline(self.moreprompt)
if line is None: # unexpected eof
raise self.Error("Incomplete SQL (line %d of %s): %s\n" % (self.input_line_number, getattr(self.stdin, "name", ""), command))
if line in ("go", "/"):
break
command=command+"\n"+line
return command
except KeyboardInterrupt:
self.handle_interrupt()
return ""
For dot commands it will be one line. For SQL statements it
will be as many as is necessary to have a
:meth:`~apsw.complete` statement (ie semicolon terminated).
Returns None on end of file."""
try:
self._completion_first=True
command=self.getline(self.prompt)
if command is None:
return None
if len(command.strip())==0:
return ""
if command[0]=="?":
command=".help "+command[1:]
# incomplete SQL?
while command[0]!="." and not apsw.complete(command):
self._completion_first=False
line=self.getline(self.moreprompt)
if line is None: # unexpected eof
raise self.Error("Incomplete SQL (line %d of %s): %s\n" % (self.input_line_number, getattr(self.stdin, "name", ""), command))
if line in ("go", "/"):
break
command=command+"\n"+line
return command
except KeyboardInterrupt:
self.handle_interrupt()
return ""
printterm("Automatic reload is now: " + str(automatic_reload))
else:
validcommand=False
printterm("""unknown command. Enter ".help" for help""")
if validcommand:
histstatement='.'+command+' '+argument+rest
try:
readline.add_history(histstatement.encode('utf-8'))
except:
pass
if statement:
histstatement=statement
while not apsw.complete(statement):
more = raw_input_no_history(' ..> ')
if more==None:
statement=None
break
more=more.decode(output_encoding)
statement = statement + '\n'.decode(output_encoding) + more
histstatement=histstatement+' '+more
reloadfunctions()
number_of_kb_exceptions=0
if not statement:
printterm()
continue
try:
if not validcommand:
readline.add_history(histstatement.encode('utf-8'))