# QAN doesn't display query from python script

**URL:** <https://forums.percona.com/t/qan-doesnt-display-query-from-python-script/36849>\
**Category:** PMM 2.x\
**Created:** [February 21, 2025, 11:22am UTC](https://forums.percona.com/t/qan-doesnt-display-query-from-python-script/36849 "2025-02-21T11:22:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dba\_S4dscjz](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@dba\_S4dscjz](https://forums.percona.com/u/dba_S4dscjz)\
**Post date:** [February 21, 2025, 11:22am UTC](https://forums.percona.com/t/qan-doesnt-display-query-from-python-script/36849/1 "2025-02-21T11:22:33Z")

</div>

Hello all,

For our business needs we realize some tasks with python scripts and we notice that several queries are not displayed in the QAN page inside PMM web interface.

After several tests we found a first hint but before here some details about the test environment :

- OS : Ubuntu Server 22.04 LTS
- Database server : MySQL community version 8.0.40
- PMM server : 2.43.2 (docker version in another server under Ubuntu)
- Python : 3.10.12
- Connector : Python/Connector 9.1.0 provided by Oracle

Now we can reproduce the case

```auto
import mysql.connector
conn = mysql.connector.connect(host='127.0.0.1',user='test_user',password='test_password',database='test',port=3306)
cur = conn.cursor()
cur.execute("SELECT SLEEP(30)")
cur.fetchone()
cur.close()
conn.disconnect()

```

The query for this example is not the real business query but it’s easy to see it in QAN (this is a long query therefore QAN shows it as top query).  
In this case there is no problem, the query is well displayed in QAN

Now a second example :

```auto
import mysql.connector
conn = mysql.connector.connect(host='127.0.0.1',user='test_user',password='test_password',database='test',port=3306)
cur = conn.cursor(prepared=True)
cur.execute("SELECT SLEEP(40)")
cur.fetchone()
cur.close()
conn.disconnect()

```

In this case Python code finishes without error but the query doesn’t appear in QAN. So it’s seems that the cursor option (`prepared=True`) has an impact.

From this point we are a little bit lost because we don’t know where to search.

Any help would be appreciated,  
Thanks.

---

<div class="post-metadata">

**Author:** ![nurlan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/nurlan/32/1523_2.png) [@nurlan](https://forums.percona.com/u/nurlan)\
**Post date:** [February 24, 2025, 2:56pm UTC](https://forums.percona.com/t/qan-doesnt-display-query-from-python-script/36849/2 "2025-02-24T14:56:02Z")

</div>

Hi, yes, currently prepared statements is missing part of QAN. it might appear with different name like EXEC PRST or something like that. We are researching the way to store this kind of queries without additional harm to DB server.

---

<div class="post-metadata">

**Author:** ![dba\_S4dscjz](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@dba\_S4dscjz](https://forums.percona.com/u/dba_S4dscjz)\
**Post date:** [February 24, 2025, 5:00pm UTC](https://forums.percona.com/t/qan-doesnt-display-query-from-python-script/36849/3 "2025-02-24T17:00:26Z")

</div>

Hello @nurlan,

Thank you for your answer.  
Do you know if you’re close to finding a solution ?
