Get the SQL executed by dataset (Python OR mapper).
dataset: 1.3.2 mysqlclient: 1.4.6
Must be ↓ in advance.
db = dataset.connect(url)
result = db.query("select * from test1")
result.result_proxy.context.statement
> 'select * from test1'
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'
Both query ()
and find ()
return dataset.util.ResultIter
.
https://github.com/pudo/dataset/blob/68a8ad8c2bea8e34f100381312fe1fd54ee41399/dataset/util.py#L36
Recommended Posts