More flexible --sql-file

This commit is contained in:
Miroslav Stampar 2015-08-23 22:54:08 +02:00
parent 337eb9861a
commit 76c8ce0e70

View File

@ -120,9 +120,12 @@ class Custom:
if not sfile:
continue
query = getSQLSnippet(Backend.getDbms(), sfile)
snippet = getSQLSnippet(Backend.getDbms(), sfile)
infoMsg = "executing SQL statement%s from file '%s'" % ("s" if ";" in query else "", sfile)
logger.info(infoMsg)
conf.dumper.query(query, self.sqlQuery(query))
if snippet and all(query.strip().upper().startswith("SELECT") for query in filter(None, snippet.split(';' if ';' in snippet else '\n'))):
for query in filter(None, snippet.split(';' if ';' in snippet else '\n')):
query = query.strip()
if query:
conf.dumper.query(query, self.sqlQuery(query))
else:
conf.dumper.query(snippet, self.sqlQuery(snippet))