def sea_sigle_insert(now, versionid=0): sql = f"insert into main_route(route_id, start, end, boat, route, departual, arrival, status, places, price, company, href, country, area, versionid) " \ f"values(\"{now['route_id']}\",\"{now['start']}\",\"{now['end']}\",\"{now['boat']}\",\"{now['route']}\",\"{now['departual']}\"," \ f"\"{now['arrival']}\",\"{now['status']}\",\"{now['places']}\",\"{now['price']}\"," \ f"\"{now['company']}\",\"{now['href']}\",\"{now['country']}\",\"{now['area']}\", {versionid})" # print(sql) sql_handle.sql_excute(sql)
def sql_update_data(update_str, data, match=None, table="boat"): if table == "boat": sql = f"update main_boat set {update_str}=\"{data}\" where boat=\"{match}\"" else: sql = f"update route_detail set {update_str}=\"{data}\" where route=\"{match}\"" print(sql) sql_handle.sql_excute(sql)
def update_route_site_detail(route, new, loc=None, site=None): sql = f"update route_site_detail set versionid={new} where route=\"{route}\" and company=\"{COMPANY}\" " if loc is not None: sql += f" and versionid={loc}" if site is not None: sql += f" and site=\"{site}\" " # print(sql) sql_handle.sql_excute(sql)
def insert_route_detail(route, decription, itinerary, versionid=0, description_zh="", day_arrange_zh=""): sql = f"INSERT INTO route_detail(company, route, description, day_arrange, versionid, description_zh, day_arrange_zh) " \ f"VALUES(\"{COMPANY}\", \"{route}\", \"{decription}\", \"{itinerary}\", '{versionid}', \"{description_zh}\", \"{day_arrange_zh}\")" print(sql) sql_handle.sql_excute(sql)
def insert_main_boat(boat, guest, length, width, speed, wifi, nitrox, description, accommodation, description_zh="", accommodation_zh="", versionid=0): sql = f"INSERT INTO main_boat (company, boat, guest, length, width, speed, wifi, nitrox, description, accommodation,description_zh, accommodation_zh, versionid) " \ f"VALUES(\"{COMPANY}\", \"{boat}\", \"{guest}\", \"{length}\", '{width}', \"{speed}\", \"{wifi}\", \"{nitrox}\", \"{description}\"," \ f" \"{accommodation}\", \"{description_zh}\", \"{accommodation_zh}\", {versionid})" # print(sql) sql_handle.sql_excute(sql)
def excute_sql(sql): sql_handle.sql_excute(sql)
def clear_sites_data(): sql = f"delete from route_site_detail where versionid=2 and company=\"{COMPANY}\"" sql_handle.sql_excute(sql)
def insert_site_detail(route, site, depth, diffculty, rank, versionid=0): sql = f"INSERT INTO route_site_detail(company, route, site, depth, difficulty, rank, versionid)" \ f" VALUES(\"{COMPANY}\",\"{route}\",'{site}','{depth}','{diffculty}',{rank},'{versionid}')" print(sql) sql_handle.sql_excute(sql)
def clear_main_boat_data(): sql = f"delete from main_boat where versionid=2 and company=\"{COMPANY}\"" sql_handle.sql_excute(sql)
def update_main_boats(boat, new, loc=None): sql = f"update main_boat set versionid={new} where boat=\"{boat}\" and company=\"{COMPANY}\" " if loc is not None: sql += f" and versionid={loc}" sql_handle.sql_excute(sql)