databases icon indicating copy to clipboard operation
databases copied to clipboard

get last run statement for debugging

Open bendog opened this issue 6 years ago • 5 comments

Firstly, great project!

There might be a way to access this already but...

I'm trying to work out why what looks like a perfectly well formed SQLite query, which works fine in MySQL, is failing in one very specific use case.

It would be helpful if i could get a .last_query or .queries property to display the exact query which was sent, after it had been generated.

Or a way to access the same build tool that will be used to merge the query and the query values.

Thanks

bendog avatar Dec 17 '19 05:12 bendog

Have you looked into the debug logging that databases provides? Is that sufficient?

lovelydinosaur avatar Dec 17 '19 10:12 lovelydinosaur

It's also possible to print(query) or str(query) before passing to the connection.

gvbgduh avatar Dec 17 '19 11:12 gvbgduh

Have you looked into the debug logging that databases provides? Is that sufficient?

One very easy way to close this request would be to add a mention of this to the docs. I can't find any reference to "logging" "debug", and so on in those docs.

I got what I needed by just running

logging.getLogger("databases").setLevel(logging.DEBUG)

corydodt avatar Feb 02 '21 01:02 corydodt

I need to see the compiled query too. I have tried @corydodt's code snippet but I can't see any output yet. Does anyone has any other clue about why I can't see any log output from databases in my project?

matiasbeckerle avatar Mar 12 '21 13:03 matiasbeckerle