from mysql.create_table import cre_db_table from mysql.read_MappingTable import mappingtable_part, mappingtable_car host = 'localhost' # mysql的ip或者本地的地址 user = '******' # mydql的用户 pw = 'mysql-qd' # mysql的密码 map_database = 'MappingTable' #映射表数据据库名称 cars = ['Bora_MQB'] parts_list = [] standard_parts = mappingtable_part(host, user, pw, map_database)[0] # 映射表标准零件缩写的列表 for standard_part in standard_parts.values(): parts_list.append(standard_part) parts_list = list(sorted(set(parts_list))) #去重复的零件缩写 cars_list = [] standard_cars = mappingtable_car(host, user, pw, map_database)[0] # 映射表标准零件缩写的列表 for standard_car in standard_cars.values(): cars_list.append(standard_car) cars_list = list(sorted(set(cars_list))) #去重复的零件缩写 print(standard_parts) print(parts_list) print(cars_list) def creat_db(car): database = car table = 'mail_address'
user = '******' #mydql的用户 pw = 'mysql-qd1' #mysql的密码 map_database = 'MappingTable' #映射表数据据库名称 program_addr = os.path.split(os.path.realpath(__file__))[0] #dmo存放的绝对地址 dmo_file = program_addr + r'\DMO' #读取dmo出现错误是的接收文件夹 dmo_error_file = program_addr + r'\DMO_Error' #有预警是这个文件夹会生成一个txt文件 gentxtfolder_addr = program_addr + r'\03_Gen_txt' #出现 dict_cars = mappingtable_car(host, user, pw, map_database)[0] #映射表车型的字典 # standard_cars=mappingtable_car(host, user, pw, map_database)[1]#映射表标准车型缩写的列表 dict_parts = mappingtable_part(host, user, pw, map_database)[0] #映射表零件的字典 # standard_parts=mappingtable_part (host, user, pw, map_database)[0]#映射表标准零件缩写的列表 tipdir = program_addr + '\\循环读取DMO不要删除.txt' with open(tipdir, 'w') as f: pass dmo_list = os.listdir(dmo_file) # 获取dmo的名称列表 print(dmo_list) #循环读取每个dmo把信息写入数据库 try: for dmo_name in dmo_list: # dmo的路径 dmo_addr = dmo_file + '\\' + dmo_name print(dmo_addr)