Executes the given SQL query and return a list of rows. With commit=True, automatically commits insert/update/delete changes.
(self, SQL, commit=False)
| 529 | return self._query |
| 530 | |
| 531 | def execute(self, SQL, commit=False): |
| 532 | """ Executes the given SQL query and return a list of rows. |
| 533 | With commit=True, automatically commits insert/update/delete changes. |
| 534 | """ |
| 535 | self._query = SQL |
| 536 | if not SQL: |
| 537 | return # MySQL doesn't like empty queries. |
| 538 | #print SQL |
| 539 | cursor = self._connection.cursor() |
| 540 | cursor.execute(SQL) |
| 541 | rows = list(cursor.fetchall()) |
| 542 | cursor.close() |
| 543 | if commit is not False: |
| 544 | self._connection.commit() |
| 545 | return rows |
| 546 | |
| 547 | def commit(self): |
| 548 | """ Commit all pending insert/update/delete changes. |