Fetch the repository succeeded.
This action will force synchronization from liuyueming/noaa, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
from toolbox import BaiduMap
from config import *
baidu_api = BaiduMap(BD_AK)
import pymysql
def insert_station_info():
db = pymysql.connect(host=HOST, user=USER, passwd=PASSWORD, db=DB, charset=CHARSET)
cursor = db.cursor()
# 查找数据库,如果station重复则保留一个结果
station_number = cursor.execute('select * from data group by station having count(station)>1')
# 所有查询结果
station_result = cursor.fetchall()
# 遍历所有结果,然后把数据插入info表,其中字段station_id name latitude longitude从原始表data取值不修改
# 字段country province city district分别代表国家,省份,城市,县或区级信息是通过传递经纬度调用百度api取到的
for i in station_result:
#print(baidu_api.get_location(i[2],i[3]))
sql = 'insert into info values(%s, %s, %s, %s, %s, %s, %s, %s)'
values = [i[0],i[5],i[2],i[3],baidu_api.get_location(i[2],i[3])['country'],baidu_api.get_location(i[2],i[3])['province'],baidu_api.get_location(i[2],i[3])['city'],baidu_api.get_location(i[2],i[3])['district']]
print(values)
cursor.execute(sql,values)
db.commit()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。