MCPcopy
hub / github.com/PyMySQL/PyMySQL / safe_create_table

Method safe_create_table

pymysql/tests/base.py:89–105  ·  view source on GitHub ↗

create a table. Ensures any existing version of that table is first dropped. Also adds a cleanup rule to drop the table after the test completes.

(self, connection, tablename, ddl, cleanup=True)

Source from the content-addressed store, hash-verified

87 self._connections = None
88
89 def safe_create_table(self, connection, tablename, ddl, cleanup=True):
90 """create a table.
91
92 Ensures any existing version of that table is first dropped.
93
94 Also adds a cleanup rule to drop the table after the test
95 completes.
96 """
97 cursor = connection.cursor()
98
99 with warnings.catch_warnings():
100 warnings.simplefilter("ignore")
101 cursor.execute(f"drop table if exists `{tablename}`")
102 cursor.execute(ddl)
103 cursor.close()
104 if cleanup:
105 self.addCleanup(self.drop_table, connection, tablename)
106
107 def drop_table(self, connection, tablename):
108 cursor = connection.cursor()

Callers 11

test_binaryMethod · 0.80
test_blobMethod · 0.80
test_single_tupleMethod · 0.80
test_jsonMethod · 0.80
setUpMethod · 0.80
setUpMethod · 0.80
test_issue_33Method · 0.80
test_issue_321Method · 0.80
test_issue_364Method · 0.80
test_issue_363Method · 0.80

Calls 3

cursorMethod · 0.80
executeMethod · 0.80
closeMethod · 0.45

Tested by 11

test_binaryMethod · 0.64
test_blobMethod · 0.64
test_single_tupleMethod · 0.64
test_jsonMethod · 0.64
setUpMethod · 0.64
setUpMethod · 0.64
test_issue_33Method · 0.64
test_issue_321Method · 0.64
test_issue_364Method · 0.64
test_issue_363Method · 0.64