(self, query, params=None)
| 87 | return query, params |
| 88 | |
| 89 | def execute(self, query, params=None): |
| 90 | if query.upper().strip("; ") == "VACUUM": |
| 91 | self.db.commit("vacuum called") |
| 92 | query = query.strip() |
| 93 | while self.db.progress_sleeping: |
| 94 | time.sleep(0.1) |
| 95 | |
| 96 | self.db.last_query_time = time.time() |
| 97 | |
| 98 | query, params = self.parseQuery(query, params) |
| 99 | |
| 100 | s = time.time() |
| 101 | |
| 102 | if params: # Query has parameters |
| 103 | res = self.cursor.execute(query, params) |
| 104 | if self.logging: |
| 105 | self.db.log.debug(query + " " + str(params) + " (Done in %.4f)" % (time.time() - s)) |
| 106 | else: |
| 107 | res = self.cursor.execute(query) |
| 108 | if self.logging: |
| 109 | self.db.log.debug(query + " (Done in %.4f)" % (time.time() - s)) |
| 110 | |
| 111 | # Log query stats |
| 112 | if self.db.collect_stats: |
| 113 | if query not in self.db.query_stats: |
| 114 | self.db.query_stats[query] = {"call": 0, "time": 0.0} |
| 115 | self.db.query_stats[query]["call"] += 1 |
| 116 | self.db.query_stats[query]["time"] += time.time() - s |
| 117 | |
| 118 | if not self.db.need_commit: |
| 119 | query_type = query.split(" ", 1)[0].upper() |
| 120 | if query_type in ["UPDATE", "DELETE", "INSERT", "CREATE"]: |
| 121 | self.db.need_commit = True |
| 122 | |
| 123 | return res |
| 124 | |
| 125 | # Creates on updates a database row without incrementing the rowid |
| 126 | def insertOrUpdate(self, table, query_sets, query_wheres, oninsert={}): |
no test coverage detected