From 23b46411eaf053f41b2b268a9f9456332d177716 Mon Sep 17 00:00:00 2001 From: Gary Daigle Date: Sat, 14 May 2016 14:40:30 -0400 Subject: [PATCH 1/2] Added lastQuery Added lastQuery to return the last SQL statement executed by the cursor. --- simplemysql/simplemysql.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/simplemysql/simplemysql.py b/simplemysql/simplemysql.py index e8be4f2..a7c866c 100644 --- a/simplemysql/simplemysql.py +++ b/simplemysql/simplemysql.py @@ -8,6 +8,7 @@ getOne() - get a single row getAll() - get all rows lastId() - get the last insert id + lastQuery() - get the last executed query insert() - insert a row insertOrUpdate() - insert a row or update it if it exists update() - update rows @@ -101,6 +102,13 @@ def lastId(self): """Get the last insert id""" return self.cur.lastrowid + def lastQuery(self): + """Get the last executed query""" + try: + return self.cur.statement + except AttributeError: + return self.cur._last_executed + def leftJoin(self, tables=(), fields=(), join_fields=(), where=None, order=None, limit=None): """Run an inner left join query From f0e70a4ddd22e1fba7151017d17f27c8188f8d82 Mon Sep 17 00:00:00 2001 From: Gary Daigle Date: Sat, 14 May 2016 14:46:09 -0400 Subject: [PATCH 2/2] Updated README.md for lastQuery --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 655002c..761dbee 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,9 @@ books = db.getAll("books", # lastId() Get the last insert id +# lastQuery() +Get the last query executed + # delete(table, fields[], condition[], order[], limit[]) Delete one or more records based on a condition (or no condition)