我正在使用它的查询:
ST = "INSERT INTO oky (file_number,occurred_on, road_condition, weather, relation_roadway, primary_factor, alignment, surface_type, district, surface_condition, tot_veh, location_kind, st_name, zone, subzone, subzone, access_control, geolocation_address,st_number, road_type, lighting, manner_of_collision,geolocation_city, crash_date,crash_time, st_type, closest_street, geolocation)
VALUES ( "\+str(dbfile_number)+ ',' + str(dboccured_on)+',' +dbroad_condition+ ',' +dbweather+ ',' +dbRelation_roadway+ ',' +dbPrimary_factor+ ',' +dbAlignment+ ',' +dbSurface_condition+ ','+dbTot_ve+dbRelation_roadway+ ',' +dbPrimary_factor+ ',' +dbAlignment+ ',' +dbSurface_condition+ ','+dbTot_veh+ ',' +dbLocation_kind+ ','+dbSt_name+','+bZone','+dbSubzone+',' +dbAccess_control+','+dbGeolocation_address+','+dbst_number+','+dbLightning+','+dbManner_of_collision+',' +dbGeolocation_city+','+dbCrash_date+','+dbCrash_time+','+dbSt_type+','+dbClosest_street+','+dbClosest_street+','+dbGeolocation+")"
我得到的错误是:
SyntaxError:行继续符后的意外字符 来自剧本
任何人都可以通过告诉我的错误来帮助我吗?
提前致谢。
答案 0 :(得分:0)
这应该有所帮助。
ST = "INSERT INTO oky (file_number,occurred_on, road_condition, weather, relation_roadway, primary_factor, alignment, surface_type, district, surface_condition, tot_veh, location_kind, st_name, zone, subzone, subzone, access_control, geolocation_address,st_number, road_type, lighting, manner_of_collision,geolocation_city, crash_date,crash_time, st_type, closest_street, geolocation) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);"
data = (str(dbfile_number), str(dboccured_on), dbroad_condition, dbweather, dbRelation_roadway, dbPrimary_factor, dbAlignment, dbSurface_condition, dbTot_ve, dbRelation_roadway, dbPrimary_factor, dbAlignment, dbSurface_condition, dbTot_veh, dbLocation_kind) #Add the required data.
cursor.execute(ST, data)