User Tools

Site Tools


vincent:python

ceci est du python

pytonfile.py
import mysql.connector as mariadb
import urllib.request as ulr
import simplekml
import time
import json
#connecte MariaDB
conn=mariadb.connect(host='192.168.0.131',port='3307',user='roy',database='genealogy')
cur=conn.cursor()
kml=simplekml.Kml()
#anc_id=1673247
anc_id=9999999
#cur.execute("with recursive anc as(select * from t_person where id=%s UNION select p.* from t_person p join anc on anc.idf=p.id or anc.idm=p.id) select max(py) py,max(pr) pr,lat,lon,group_concat(id,': ',Nom,' | ',Prenom SEPARATOR '\n') p from anc join plr using(id) join places on n_lid=lid or d_lid=lid where lat is not null group by lat,lon",(anc_id,))
cur.execute('''with recursive anc as(select *,0000000001 s from t_person where id=%s UNION 
select p.*,2*anc.s+(p.Sexe='F') s from t_person p join anc on anc.idf=p.id or anc.idm=p.id) 
select max(py) py,max(pr) pr,lat,lon,group_concat(id,': ',Nom,' | ',Prenom,' : ',st SEPARATOR '\n') p from (select * from (select id,min(strad(s)) st from anc group by id) ancs join (select distinct id,idf,idm,Nom,Prenom from anc)ancp using(id) ) ancf
join plr using(id)
join places on n_lid=lid or d_lid=lid 
where lat is not null group by lat,lon''',(anc_id,))
 
for i in cur.fetchall():
    #print(i[0]+' '+i[1],[i[2],i[3]])
    pnt=kml.newpoint(name=i[0]+' '+i[1], coords=[(i[3],i[2])])
    pnt.description = i[4]
kml.save("VR.kml")
vincent/python.txt · Last modified: 2019/05/03 22:05 by admin