drop_table.py
1 # SPDX-FileCopyrightText: 2023 LakeSoul Contributors 2 # 3 # SPDX-License-Identifier: Apache-2.0 4 5 import pymysql 6 7 table_num = 15 8 table_type = 4 9 host = 'localhost' 10 user = 'root' 11 password = 'root' 12 port = 3306 13 db = 'ddf_1' 14 15 property = {} 16 17 with open("./properties") as file: 18 for line in file.readlines(): 19 line = line.strip() 20 if line.find('=') > 0 and not line.startswith('#'): 21 strs = line.split('=') 22 property[strs[0].strip()] = strs[1].strip() 23 24 table_num = int(property['table_num']) 25 host = property['host'] 26 user = property['user'] 27 password = property['password'] 28 port = int(property['port']) 29 db = property['db'] 30 31 connect = pymysql.connect(host=host, 32 user=user, 33 password=password, 34 port=port, 35 db=db, 36 charset='utf8') 37 38 cur = connect.cursor() 39 40 cur.execute("drop table if exists default_init") 41 cur.execute("drop table if exists default_init_1") 42 for i in range(table_num): 43 cur.execute("drop table if exists random_table_%s" % str(i)) 44 45 connect.commit() 46 cur.close() 47 connect.close()