def setUp(self):
# ???????
try:
self.session.execute("DROP DATABASE test_spider;")
except OperationalError as e:
logging.warning(e)
self.session.execute("CREATE DATABASE test_spider CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;")
# ??????? test_spider
self.session.execute("USE test_spider;")
path = os.path.dirname(__file__)
execute_sql_file(
file_paths=[os.path.join(path, "schema.sql"), ],
db_session=self.session
)
fixture_path = os.path.join(path, 'fixture')
# ?? fixture ?? SQL ??......
fixture_file_paths = [os.path.join(fixture_path, file) for file in os.listdir(fixture_path)]
execute_sql_file(
file_paths=fixture_file_paths,
db_session=self.session
)
评论列表
文章目录