executes an sql query
(self, cur, sql_query)
| 735 | raise UnknownParamstyle(style) |
| 736 | |
| 737 | def _db_execute(self, cur, sql_query): |
| 738 | """executes an sql query""" |
| 739 | self.ctx.dbq_count += 1 |
| 740 | |
| 741 | try: |
| 742 | a = time.time() |
| 743 | query, params = self._process_query(sql_query) |
| 744 | out = cur.execute(query, params) |
| 745 | b = time.time() |
| 746 | except: |
| 747 | if self.printing: |
| 748 | print("ERR:", str(sql_query), file=debug) |
| 749 | if self.ctx.transactions: |
| 750 | self.ctx.transactions[-1].rollback() |
| 751 | else: |
| 752 | self.ctx.rollback() |
| 753 | raise |
| 754 | |
| 755 | if self.printing: |
| 756 | print( |
| 757 | f"{round(b - a, 2)} ({self.ctx.dbq_count}): {str(sql_query)}", |
| 758 | file=debug, |
| 759 | ) |
| 760 | return out |
| 761 | |
| 762 | def _process_query(self, sql_query): |
| 763 | """Takes the SQLQuery object and returns query string and parameters.""" |
no test coverage detected