Skip to content

Commit 32f9638

Browse files
committed
Add table creation in docstring examples
1 parent eddb1f9 commit 32f9638

File tree

6 files changed

+13
-2
lines changed
  • instrumentation
    • opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg
    • opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql
    • opentelemetry-instrumentation-mysqlclient/src/opentelemetry/instrumentation/mysqlclient
    • opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg
    • opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2
    • opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3

6 files changed

+13
-2
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
3131
cnx = await aiopg.connect(database='Database')
3232
cursor = await cnx.cursor()
33+
await cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
3334
await cursor.execute("INSERT INTO test (testField) VALUES (123)")
3435
cursor.close()
3536
cnx.close()
@@ -38,6 +39,7 @@
3839
3940
cnx = await pool.acquire()
4041
cursor = await cnx.cursor()
42+
await cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
4143
await cursor.execute("INSERT INTO test (testField) VALUES (123)")
4244
cursor.close()
4345
cnx.close()
@@ -51,6 +53,7 @@
5153
cnx = await aiopg.connect(database='Database')
5254
instrumented_cnx = AiopgInstrumentor().instrument_connection(cnx)
5355
cursor = await instrumented_cnx.cursor()
56+
await cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
5457
await cursor.execute("INSERT INTO test (testField) VALUES (123)")
5558
cursor.close()
5659
instrumented_cnx.close()

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

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
3232
cnx = mysql.connector.connect(database="MySQL_Database")
3333
cursor = cnx.cursor()
34+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
3435
cursor.execute("INSERT INTO test (testField) VALUES (123)")
3536
cursor.close()
3637
cnx.close()
@@ -44,6 +45,7 @@
4445
cnx = mysql.connector.connect(database="MySQL_Database")
4546
instrumented_cnx = MySQLInstrumentor().instrument_connection(cnx)
4647
cursor = instrumented_cnx.cursor()
48+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
4749
cursor.execute("INSERT INTO test (testField) VALUES (123)")
4850
cursor.close()
4951
instrumented_cnx.close()

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

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
5252
cnx = MySQLdb.connect(database="MySQL_Database")
5353
cursor = cnx.cursor()
54+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
5455
cursor.execute("INSERT INTO test (testField) VALUES (123)"
5556
cnx.commit()
5657
cursor.close()
@@ -73,6 +74,7 @@
7374
}
7475
)
7576
cursor = instrumented_cnx.cursor()
77+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
7678
cursor.execute("INSERT INTO test (testField) VALUES (123)"
7779
instrumented_cnx.commit()
7880
cursor.close()

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

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
cnx = psycopg.connect(database='Database')
9595
9696
cursor = cnx.cursor()
97+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
9798
cursor.execute("INSERT INTO test (testField) VALUES (123)")
9899
cursor.close()
99100
cnx.close()
@@ -107,6 +108,7 @@
107108
cnx = psycopg.connect(database='Database')
108109
instrumented_cnx = PsycopgInstrumentor().instrument_connection(cnx)
109110
cursor = instrumented_cnx.cursor()
111+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
110112
cursor.execute("INSERT INTO test (testField) VALUES (123)")
111113
cursor.close()
112114
instrumented_cnx.close()

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

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
cnx = psycopg2.connect(database='Database')
9595
9696
cursor = cnx.cursor()
97+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
9798
cursor.execute("INSERT INTO test (testField) VALUES (123)")
9899
cursor.close()
99100
cnx.close()
@@ -107,6 +108,7 @@
107108
cnx = psycopg2.connect(database='Database')
108109
instrumented_cnx = Psycopg2Instrumentor().instrument_connection(cnx)
109110
cursor = instrumented_cnx.cursor()
111+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
110112
cursor.execute("INSERT INTO test (testField) VALUES (123)")
111113
cursor.close()
112114
instrumented_cnx.close()

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
3333
cnx = sqlite3.connect(':memory:')
3434
cursor = cnx.cursor()
35-
cursor.execute("CREATE TABLE test (testField INTEGER)")
35+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
3636
cursor.execute("INSERT INTO test (testField) VALUES (123)")
3737
cursor.close()
3838
cnx.close()
@@ -46,7 +46,7 @@
4646
conn = sqlite3.connect(":memory:")
4747
instrumented_connection = SQLite3Instrumentor().instrument_connection(conn)
4848
cursor = instrumented_connection.cursor()
49-
cursor.execute("CREATE TABLE test (testField INTEGER)")
49+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
5050
cursor.execute("INSERT INTO test (testField) VALUES (123)")
5151
cursor.execute("SELECT * FROM test")
5252
cursor.close()

0 commit comments

Comments
 (0)