Skip to content

Commit 02dc87e

Browse files
authored
Improve pymysql instrumentation examples (#3472)
1 parent e6869cd commit 02dc87e

File tree

1 file changed

+6
-5
lines changed
  • instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql

1 file changed

+6
-5
lines changed

instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
3232
cnx = pymysql.connect(database="MySQL_Database")
3333
cursor = cnx.cursor()
34-
cursor.execute("INSERT INTO test (testField) VALUES (123)"
34+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
35+
cursor.execute("INSERT INTO test (testField) VALUES (123)")
3536
cnx.commit()
3637
cursor.close()
3738
cnx.close()
3839
39-
4040
.. code:: python
4141
4242
import pymysql
@@ -53,7 +53,8 @@
5353
}
5454
)
5555
cursor = instrumented_cnx.cursor()
56-
cursor.execute("INSERT INTO test (testField) VALUES (123)"
56+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
57+
cursor.execute("INSERT INTO test (testField) VALUES (123)")
5758
instrumented_cnx.commit()
5859
cursor.close()
5960
instrumented_cnx.close()
@@ -75,12 +76,12 @@
7576
7677
cnx = pymysql.connect(database="MySQL_Database")
7778
cursor = cnx.cursor()
78-
cursor.execute("INSERT INTO test (testField) VALUES (123)"
79+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
80+
cursor.execute("INSERT INTO test (testField) VALUES (123)")
7981
cnx.commit()
8082
cursor.close()
8183
cnx.close()
8284
83-
8485
For example,
8586
::
8687

0 commit comments

Comments
 (0)