Executes a query with a WITH clause, fetching all rows
(self, args)
| 1638 | self._build_query_string(self.last_leading_comment, self.orig_cmd, args)) |
| 1639 | |
| 1640 | def do_with(self, args): |
| 1641 | """Executes a query with a WITH clause, fetching all rows""" |
| 1642 | query = self._build_query_string(self.last_leading_comment, self.orig_cmd, args) |
| 1643 | # Parse the query with sqlparse to identify if it is a DML query or not. |
| 1644 | # Because the WITH clause may precede DML or SELECT queries, checking the |
| 1645 | # first string token is insufficient. |
| 1646 | parsed = sqlparse.parse(query)[0] |
| 1647 | query_type = sqlparse.sql.Statement(parsed.tokens).get_type() |
| 1648 | try: |
| 1649 | is_dml = self.DML_REGEX.match(query_type.lower()) |
| 1650 | return self._execute_stmt(query, bool(is_dml), print_web_link=True) |
| 1651 | except ValueError: |
| 1652 | return self._execute_stmt(query, print_web_link=True) |
| 1653 | |
| 1654 | def do_use(self, args): |
| 1655 | """Executes a USE... query""" |
nothing calls this directly
no test coverage detected