Get the SQL executed by dataset (Python OR mapper)

Overview

Get the SQL executed by dataset (Python OR mapper).

dataset: 1.3.2 mysqlclient: 1.4.6

dataset official

Implementation

Premise

Must be ↓ in advance.

db = dataset.connect(url)

When query ()

result = db.query("select * from test1")

result.result_proxy.context.statement
> 'select * from test1'

When find ()

table: dataset.Table = db['test1']
result = table.find()

result.result_proxy.context.statement
> 'SELECT test1.id \nFROM test1 \n LIMIT %s, 18446744073709551615'

Or

result = iter(db['test1'])

result.result_proxy.context.statement
> 'SELECT test1.id \nFROM test1 \n LIMIT %s, 18446744073709551615'

Remarks

Both query () and find () return dataset.util.ResultIter.

https://github.com/pudo/dataset/blob/68a8ad8c2bea8e34f100381312fe1fd54ee41399/dataset/util.py#L36

Recommended Posts

Get the SQL executed by dataset (Python OR mapper)
[Python] Get the previous month
[Python] Which is executed first, the class variable or __init__?
Get the desktop path in Python
Get the weather with Python requests
Get the weather with Python requests 2
Get the script path in Python
How to get the Python version
python sql statement extracted by time
Get the desktop path in Python
Get the host name in Python
Python Note: Get the current month
[Python Kivy] How to get the file path by dragging and dropping
Get property information by scraping with python
Python> dictionary> values ()> Get All Values by Using values ()
OR the List in Python (zip function)
Read the file line by line in Python
Read the file line by line in Python
Pandas of the beginner, by the beginner, for the beginner [Python]
[Python] Get the character code of the file
Get the EDINET code list in Python
[Python] Get the main color from the screenshot
Get Unix time of the time specified by JST regardless of the time zone of the server in Python
Get coordinate values and keyboard input values by clicking on the python / matplotlib diagram
Get the last element of the array by splitting the string in Python and PHP
Get the contents of git diff from python
[Python] Get the files in a folder with Python
Get the weather in Osaka via WebAPI (python)
The first web app created by Python beginners
[Python] Get / edit the scale label of the figure
[Python] Get the main topics of Yahoo News
Get the caller of a function in Python
Super easy OR mapper dataset for lazy people
[Django] How to get data by specifying SQL.
Get the X Window System window title in Python
[Python] Sort the table by sort_values (pandas DataFrame)
[Python] Get the last updated date of the website
How to erase the characters output by Python
I tried using the Datetime module by Python
How to get the files in the [Python] folder
[Python] Get the day of the week (English & Japanese)
Get the update date of the Python memo file.
Get the location of the file where the exe is placed when the exe created by PyInstaller is executed