698 lines
38 KiB
Python
698 lines
38 KiB
Python
import psycopg2
|
||
from psycopg2.extras import *
|
||
import uuid
|
||
import datetime
|
||
import csv
|
||
|
||
|
||
|
||
'''
|
||
|
||
DB_PATH_MAIN = "host=localhost dbname=alloaV3 user=mad password=mad8888"
|
||
|
||
|
||
DB_PATH_WEB_CLIENT = "host=localhost dbname=alloaWebclientV3 user=mad password=mad8888"
|
||
|
||
|
||
|
||
class DB:
|
||
def _connect(self):
|
||
if self.path == "main":
|
||
self.db = psycopg2.connect(self.DB_PATH_MAIN)
|
||
elif self.path == 'web_client':
|
||
self.db = psycopg2.connect(self.DB_PATH_WEB_CLIENT)
|
||
|
||
self.cur = self.db.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||
self.is_connect = True
|
||
|
||
'''
|
||
|
||
'''
|
||
t_host = "localhost"
|
||
t_port = "5432"
|
||
t_dbname = "alloaWebclientV3"
|
||
t_name_user = "mad"
|
||
t_password = "mad8888"
|
||
'''
|
||
db_conn_old = psycopg2.connect(host="localhost", port="5432", dbname="alloavold", user="mad", password="mad8888")
|
||
db_cursor_old = db_conn_old.cursor()
|
||
is_connect=True
|
||
|
||
|
||
db_conn_new = psycopg2.connect(host="localhost", port="5432", dbname="dballoavv210729", user="mad", password="mad8888")
|
||
db_cursor_new = db_conn_new.cursor()
|
||
|
||
|
||
def close_old():
|
||
db_cursor_old.close()
|
||
|
||
|
||
def query_old(sql):
|
||
db_cursor_old.execute(sql)
|
||
data = db_cursor_old.fetchall()
|
||
#close()
|
||
return data
|
||
|
||
|
||
|
||
def execute_old(sql):
|
||
if not is_connect:
|
||
connect()
|
||
|
||
if debug:
|
||
print(sql)
|
||
|
||
try:
|
||
db_cursor_old.execute(sql)
|
||
valid = db_cursor_old.rowcount
|
||
db_conn_old.commit()
|
||
close()
|
||
return valid
|
||
print(sql)
|
||
except psycopg2.Error as e:
|
||
if e.pgcode == '23503':
|
||
db_conn_old.rollback()
|
||
return handle_error(e)
|
||
else:
|
||
raise
|
||
|
||
|
||
|
||
def close_new():
|
||
db_cursor_new.close()
|
||
|
||
|
||
def query_new(sql):
|
||
db_cursor_new.execute(sql)
|
||
data = db_cursor_new.fetchall()
|
||
#close()
|
||
return data
|
||
|
||
|
||
|
||
def execute_new(sql):
|
||
if not is_connect:
|
||
connect()
|
||
|
||
try:
|
||
db_cursor_new.execute(sql)
|
||
valid = db_cursor_new.rowcount
|
||
db_conn_new.commit()
|
||
#close()
|
||
return valid
|
||
print(sql)
|
||
except psycopg2.Error as e:
|
||
if e.pgcode == '23503':
|
||
db_conn_new.rollback()
|
||
return handle_error(e)
|
||
else:
|
||
raise
|
||
|
||
|
||
def remover():
|
||
sql="UPDATE vmap.pays SET uuidpays = '0d9665b8-32ed-412e-8f7c-110da6dce649' WHERE uuidpays = '9d9665b8-32ed-412e-8f7c-110da6dce649'; "
|
||
execute_new(sql)
|
||
|
||
|
||
#dans cette fonction, on remplace les apostrophes par des \' pour eviter les erreurs de string qui se terminent trop tot et qui causent des erreurs de syntax
|
||
def remplacer_apostrophe(cpy):
|
||
|
||
copy=[]
|
||
|
||
for i in range(len(cpy)):
|
||
liste=[]
|
||
for j in range(len(cpy[i])):
|
||
|
||
if isinstance(cpy[i][j],str)==True and isinstance(cpy[i][j],datetime.datetime)==False:
|
||
liste.append(cpy[i][j].replace("'", "’"))
|
||
else:
|
||
liste.append(cpy[i][j])
|
||
|
||
copy.append(liste)
|
||
|
||
return(copy)
|
||
|
||
|
||
def map_pays():
|
||
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM map.pays;"
|
||
cpy=query_old(copyreq)
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO vmap.pays values( '"+str(copy[i][26])+"', '"+str(copy[i][0])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][9])+"', '"+str(copy[i][8])+"', '"+str(copy[i][7])+"', '?', '"+str(copy[i][13])+"', '"+str(copy[i][12])+"', '"+str(copy[i][14])+"', '"+str(copy[i][16])+"', '"+str(copy[i][15])+"', '"+str(copy[i][17])+"','?','?','?','?', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][21])+"', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"', '"+str(copy[i][24])+"', '"+str(copy[i][1])+"','?' );")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def map_gateway():
|
||
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM map.gateway;"
|
||
cpy=query_old(copyreq)
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
checkref=[]
|
||
for i in range(len(copy)):
|
||
|
||
#ici, on verifie si la ref existe deja pour eviter les doublons
|
||
|
||
alreadyexists=False
|
||
for j in range(len(checkref)):
|
||
#print (str(checkref[j][12]))
|
||
if str(checkref[j])[0:3]==str(copy[i][13])[0:3]:
|
||
alreadyexists=True
|
||
|
||
|
||
#si la ref n'existe pas, on execute l'insertion de la ligne
|
||
if alreadyexists==False:
|
||
#print(str(copy[i][13]))
|
||
pastereq = ("INSERT INTO vmap.gateways values( '"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][9])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"','', '"+str(copy[i][12])+"', '"+str(copy[i][13])+"','','', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][17])+"', '"+str(copy[i][18])+"', '"+str(copy[i][21])+"', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"', '"+str(copy[i][24])+"', '"+str(copy[i][25])+"', '"+str(copy[i][26])+"', '"+str(copy[i][27])+"');")
|
||
execute_new(pastereq)
|
||
checkref.append(copy[i][13])
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def map_regions():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM map.region;"
|
||
cpy=query_old(copyreq)
|
||
|
||
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
print("test")
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for en rearangeant les valeurs
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO vmap.Region values( '"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '"+str(copy[i][5])+"','00:00:00.000', '"+str(copy[i][6])+"', '"+str(copy[i][10])+"', '"+str(copy[i][9])+"', '"+str(copy[i][7])+"', '?', '"+str(copy[i][14])+"', '"+str(copy[i][2])+"', 'False', '"+str(copy[i][13])+"', '"+str(copy[i][50])+"', '"+str(copy[i][15])+"', '"+str(copy[i][17])+"', '"+str(copy[i][19])+"', '"+str(copy[i][21])+"', '"+str(copy[i][23])+"', '"+str(copy[i][25])+"', '"+str(copy[i][27])+"', '"+str(copy[i][29])+"','"+str(copy[i][16])+"', '"+str(copy[i][18])+"', '"+str(copy[i][20])+"', '"+str(copy[i][22])+"', '"+str(copy[i][24])+"', '"+str(copy[i][26])+"', '"+str(copy[i][28])+"', '"+str(copy[i][30])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][33])+"', '"+str(copy[i][34])+"', '"+str(copy[i][35])+"', '"+str(copy[i][36])+"', '"+str(copy[i][37])+"', '"+str(copy[i][38])+"', '"+str(copy[i][39])+"', '"+str(copy[i][40])+"', '"+str(copy[i][41])+"', '"+str(copy[i][42])+"', '"+str(copy[i][43])+"', '"+str(copy[i][44])+"', '"+str(copy[i][45])+"', '"+str(copy[i][46])+"', '"+str(copy[i][47])+"', '"+str(copy[i][52])+"', '"+str(copy[i][53])+"', '"+str(copy[i][48])+"');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def map_ville():
|
||
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM map.ville;"
|
||
cpy=query_old(copyreq)
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
#print(str(copy[i][23]))
|
||
|
||
#select regions where ville.uuidregion = uuidregion
|
||
reg=("SELECT uuidpays FROM map.region WHERE uuidregion='"+str(copy[i][23])+"';")
|
||
reg=query_old(reg)
|
||
|
||
#print(str(reg[0][0]))
|
||
|
||
#select pays where nompays = regions.paysregion
|
||
pays=("SELECT uuidpays FROM vmap.pays WHERE uuidpays='"+str(reg[0][0])+"';")
|
||
pays=query_new(pays)
|
||
|
||
#print(str(pays[0][0]))
|
||
|
||
|
||
|
||
pastereq = ("INSERT INTO vmap.ville values( '"+str(copy[i][24])+"', '"+str(copy[i][0])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][6])+"', '"+str(copy[i][10])+"', '"+str(copy[i][8])+"', '"+str(copy[i][7])+"', '"+str(copy[i][28])+"', '"+str(copy[i][13])+"', '"+str(copy[i][1])+"', '"+str(copy[i][12])+"', '', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][17])+"', '"+str(copy[i][18])+"', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"','','','','','','"+str(pays[0][0])+"', '"+str(copy[i][21])+"', '"+str(copy[i][22])+"')")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
def map_dest():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM map.destination;"
|
||
cpy=query_old(copyreq)
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
print(str(copy[i][1]))
|
||
pastereq = ("INSERT INTO vmap.zone values( '"+str(copy[i][23])+"', '"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '00:00:00.000', '"+str(copy[i][4])+"', '"+str(copy[i][8])+"', '"+str(copy[i][7])+"', '"+str(copy[i][6])+"', '"+str(copy[i][21])+"', '"+str(copy[i][11])+"', '"+str(copy[i][12])+"', '"+str(copy[i][13])+"', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][17])+"', '"+str(copy[i][18])+"', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][21])+"','','');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
|
||
def map_zlienregiondest():
|
||
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM map.z_lien_region_destination;"
|
||
cpy=query_old(copyreq)
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO vmap.zliensdestregions values('"+str(i)+"','"+str(copy[i][1])+"', '"+str(copy[i][0])+"');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
def map_zlienregvilles():
|
||
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM map.z_lien_region_ville;"
|
||
cpy=query_old(copyreq)
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO vmap.zliensregvilles values('"+str(copy[i][0])+"','"+str(copy[i][1])+"', '"+str(copy[i][2])+"');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def og_ej():
|
||
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM ogbase.entitejuridique;"
|
||
cpy=query_old(copyreq)
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
for i in range(len(copy)):
|
||
|
||
#pastereq = ("INSERT INTO og.ej values( '"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][5])+"', '?', '0', '"+str(copy[i][7])+"', '"+str(copy[i][30])+"', '"+str(copy[i][8])+"', '"+str(copy[i][9])+"', '"+str(copy[i][10])+"', '"+str(copy[i][12])+"', '"+str(copy[i][13])+"', '"+str(copy[i][14])+"', '"+str(copy[i][20])+"', '"+str(copy[i][21])+"', '?', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"', '"+str(copy[i][24])+"', '"+str(copy[i][26])+"', '"+str(copy[i][27])+"', '"+str(copy[i][28])+"', '"+str(copy[i][29])+"', '"+str(copy[i][30])+"', '"+str(copy[i][32])+"', '"+str(copy[i][31])+"');")
|
||
pastereq = ("INSERT INTO og.ej values( '"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][3])+"', '00:00:00.000', '"+str(copy[i][5])+"', '?', '0', '"+str(copy[i][7])+"', '"+str(copy[i][30])+"', '"+str(copy[i][8])+"', '"+str(copy[i][9])+"', '"+str(copy[i][10])+"', '"+str(copy[i][12])+"', '"+str(copy[i][13])+"', '"+str(copy[i][14])+"', '"+str(copy[i][20])+"', '', '?', '01-Sep-1983', '01-Sep-1983', '01-Sep-1983', '???', '"+str(copy[i][27])+"', '"+str(copy[i][28])+"', '"+str(copy[i][29])+"', '"+str(copy[i][30])+"', '"+str(copy[i][32])+"', '"+str(copy[i][31])+"');")
|
||
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def og_oggroup():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM ogbase.oggroup;"
|
||
cpy=query_old(copyreq)
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
copyreq2="SELECT * FROM ogbase.ogstaff;"
|
||
cpy2=query_old(copyreq2)
|
||
copy2=remplacer_apostrophe(cpy2)
|
||
|
||
|
||
|
||
for i in range(len(copy)):
|
||
pastereq = ("INSERT INTO og.oggroup values( '"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][5])+"', '01-Sep-1983', '01-Sep-1983', '00:00:00.000', '"+str(copy[i][8])+"', '"+str(copy[i][0])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '0');")
|
||
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
def og_ogstaff():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM ogbase.ogstaff;"
|
||
cpy=query_old(copyreq)
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
|
||
for i in range(len(copy)):
|
||
print(len(copy[0]))
|
||
if str(copy[i][1])!="aeaze":
|
||
print("okay")
|
||
pastereq = ("INSERT INTO og.ogstaff values( '"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"', '"+str(copy[i][6])+"', '"+str(copy[i][8])+"', '"+str(copy[i][9])+"', '"+str(copy[i][21])+"', '"+str(copy[i][12])+"', '"+str(copy[i][13])+"', '"+str(copy[i][14])+"', '1983-09-01', '1983-09-01', '"+str(copy[i][19])+"', '"+str(copy[i][18])+"', '0000000000', '"+str(copy[i][15])+"', '', '"+str(copy[i][16])+"', '"+str(copy[i][17])+"', '', '', '"+str(copy[i][20])+"', '', '', '','','FALSE','FALSE','FALSE','');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
def og_ogmodule():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM ogbase.ogmodule;"
|
||
cpy=query_old(copyreq)
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
|
||
for i in range(len(copy)):
|
||
if str(copy[i][1])!="aeaze":
|
||
pastereq = ("INSERT INTO og.ogmodul values( '"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][6])+"', '"+str(copy[i][2])+"', '"+str(copy[i][7])+"', '"+str(copy[i][8])+"', '"+str(copy[i][9])+"' );")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
def ogc_classgroup():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM ogcompta.ogclassregroupement;"
|
||
cpy=query_old(copyreq)
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO ogcpta.classegroup values('"+str(copy[i][0])+"','"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][12])+"', '"+str(copy[i][8])+"', '"+str(copy[i][10])+"', '"+str(copy[i][13])+"', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"','');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def ogc_journaux():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM ogcompta.journaux;"
|
||
cpy=query_old(copyreq)
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO ogcpta.jnx values('"+str(i)+"','"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"','00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][8])+"', '"+str(copy[i][9])+"', '"+str(copy[i][11])+"');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def ogc_ecrit():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM ogcompta.ecriture;"
|
||
cpy=query_old(copyreq)
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO ogcpta.ecrit values('"+str(copy[i][0])+"','"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"','00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][10])+"','', '"+str(copy[i][27])+"', '"+str(copy[i][12])+"', '"+str(copy[i][8])+"', '"+str(copy[i][11])+"', '"+str(copy[i][29])+"','','','','01-Sep-1983', '', '"+str(copy[i][9])+"', '"+str(copy[i][14])+"','', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"','','01-Sep-1983', '"+str(copy[i][24])+"', '"+str(copy[i][38])+"', '"+str(copy[i][25])+"', '"+str(copy[i][20])+"', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"', '01-Sep-1983','');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
def prod_avv():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM production.avv;"
|
||
cpy=query_old(copyreq)
|
||
|
||
print(len(cpy))
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO vcatalog.avv values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"','00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"','', '"+str(copy[i][9])+"', '"+str(copy[i][13])+"', '"+str(copy[i][12])+"', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][18])+"', '"+str(copy[i][17])+"', '"+str(copy[i][19])+"', '"+str(copy[i][21])+"', '"+str(copy[i][20])+"', '"+str(copy[i][22])+"', '"+str(copy[i][35])+"','',, '"+str(copy[i][53])+"', '"+str(copy[i][54])+"','', '"+str(copy[i][23])+"', '"+str(copy[i][26])+"','FALSE', '"+str(copy[i][28])+"', '"+str(copy[i][27])+"', '"+str(copy[i][30])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][44])+"', '"+str(copy[i][24])+"', '"+str(copy[i][29])+"', '"+str(copy[i][33])+"','', '"+str(copy[i][34])+"', '"+str(copy[i][55])+"', '"+str(copy[i][56])+"', '"+str(copy[i][57])+"', '"+str(copy[i][40])+"', '"+str(copy[i][41])+"', '"+str(copy[i][42])+"', '"+str(copy[i][43])+"', '"+str(copy[i][45])+"', '"+str(copy[i][47])+"', '"+str(copy[i][48])+"', 'False', '"+str(copy[i][50])+"', '"+str(copy[i][51])+"', '"+str(copy[i][58])+"');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def prod_hebergement():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM production.hebergement;"
|
||
cpy=query_old(copyreq)
|
||
|
||
#print(len(cpy))
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
villes="SELECT * FROM vmap.ville;"
|
||
villes=query_new(villes)
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
villenum=-1
|
||
|
||
for j in range(len(villes)):
|
||
if str(copy[i][75])==str(villes[j][1]):
|
||
villenum=j
|
||
break;
|
||
|
||
|
||
#tous les booleens a l'index >= 83 sont non definis (none) ce qui retourne une erreur
|
||
|
||
if villenum==-1:
|
||
#pastereq = ("INSERT INTO vcatalog.hebergement values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"','00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"', '', '"+str(copy[i][9])+"', '"+str(copy[i][12])+"', '"+str(copy[i][13])+"', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][17])+"', '"+str(copy[i][18])+"', '', '', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][21])+"', '', '', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"','uuidpays (a changer)', 'codeville (a changer)','cphebergement(a changer)', '"+str(copy[i][24])+"', '"+str(copy[i][76])+"', '"+str(copy[i][77])+"','', '"+str(copy[i][25])+"', '"+str(copy[i][26])+"', '"+str(copy[i][27])+"', '"+str(copy[i][28])+"','False', '"+str(copy[i][30])+"', '"+str(copy[i][29])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][34])+"', '"+str(copy[i][35])+"', '"+str(copy[i][36])+"', '"+str(copy[i][37])+"', '"+str(copy[i][38])+"', '"+str(copy[i][39])+"', '"+str(copy[i][40])+"', '"+str(copy[i][41])+"', '"+str(copy[i][42])+"', '"+str(copy[i][43])+"', '"+str(copy[i][44])+"', '"+str(copy[i][45])+"','False', '"+str(copy[i][50])+"', '"+str(copy[i][51])+"', '"+str(copy[i][52])+"', '"+str(copy[i][53])+"', '"+str(copy[i][54])+"', '"+str(copy[i][55])+"', '"+str(copy[i][56])+"', '"+str(copy[i][57])+"', '"+str(copy[i][58])+"', '"+str(copy[i][59])+"', '"+str(copy[i][145])+"', '"+str(copy[i][164])+"','False', '"+str(copy[i][88])+"', '"+str(copy[i][115])+"', '"+str(copy[i][60])+"', '"+str(copy[i][61])+"', '"+str(copy[i][62])+"', '"+str(copy[i][63])+"', '"+str(copy[i][64])+"', '"+str(copy[i][66])+"', '"+str(copy[i][71])+"', '"+str(copy[i][72])+"', '"+str(copy[i][73])+"', '"+str(copy[i][46])+"', '"+str(copy[i][67])+"', '"+str(copy[i][65])+"', '"+str(copy[i][47])+"', '"+str(copy[i][49])+"','','', '"+str(copy[i][75])+"');")
|
||
pastereq = ("INSERT INTO vcatalog.hebergement values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"','00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"', '', '"+str(copy[i][9])+"', '"+str(copy[i][12])+"', '"+str(copy[i][13])+"', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][17])+"', '"+str(copy[i][18])+"', '', '', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][21])+"', '', '', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"','uuidpays (a changer)', 'code ND','cp ND', '"+str(copy[i][24])+"', '"+str(copy[i][76])+"', '"+str(copy[i][77])+"','', '"+str(copy[i][25])+"', '"+str(copy[i][26])+"', '"+str(copy[i][27])+"', '"+str(copy[i][28])+"','False', '"+str(copy[i][30])+"', '"+str(copy[i][29])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][34])+"', '"+str(copy[i][35])+"', '"+str(copy[i][36])+"', '"+str(copy[i][37])+"', '"+str(copy[i][38])+"', '"+str(copy[i][39])+"', '"+str(copy[i][40])+"', '"+str(copy[i][41])+"', '"+str(copy[i][42])+"', '"+str(copy[i][43])+"', '"+str(copy[i][44])+"', '"+str(copy[i][45])+"','False', '"+str(copy[i][50])+"', '"+str(copy[i][51])+"', '"+str(copy[i][52])+"', '"+str(copy[i][53])+"', '"+str(copy[i][54])+"', '"+str(copy[i][55])+"', '"+str(copy[i][56])+"', '"+str(copy[i][57])+"', '"+str(copy[i][58])+"', '"+str(copy[i][59])+"', 'False', 'False','False', 'False', 'False', '"+str(copy[i][60])+"', '"+str(copy[i][61])+"', '"+str(copy[i][62])+"', '"+str(copy[i][63])+"', '"+str(copy[i][64])+"', '"+str(copy[i][66])+"', '"+str(copy[i][71])+"', '"+str(copy[i][72])+"', '"+str(copy[i][73])+"', '"+str(copy[i][46])+"', '"+str(copy[i][67])+"', '"+str(copy[i][65])+"', '"+str(copy[i][47])+"', '"+str(copy[i][49])+"','','', '"+str(copy[i][75])+"');")
|
||
|
||
else:
|
||
#pastereq = ("INSERT INTO vcatalog.hebergement values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"','00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"', '', '"+str(copy[i][9])+"', '"+str(copy[i][12])+"', '"+str(copy[i][13])+"', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][17])+"', '"+str(copy[i][18])+"', '', '', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][21])+"', '', '', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"','"+str(villes[villenum][27])+"', '"+str(villes[villenum][13])+"','"+str(villes[villenum][19])+"', '"+str(copy[i][24])+"', '"+str(copy[i][76])+"', '"+str(copy[i][77])+"','', '"+str(copy[i][25])+"', '"+str(copy[i][26])+"', '"+str(copy[i][27])+"', '"+str(copy[i][28])+"','False', '"+str(copy[i][30])+"', '"+str(copy[i][29])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][34])+"', '"+str(copy[i][35])+"', '"+str(copy[i][36])+"', '"+str(copy[i][37])+"', '"+str(copy[i][38])+"', '"+str(copy[i][39])+"', '"+str(copy[i][40])+"', '"+str(copy[i][41])+"', '"+str(copy[i][42])+"', '"+str(copy[i][43])+"', '"+str(copy[i][44])+"', '"+str(copy[i][45])+"','False', '"+str(copy[i][50])+"', '"+str(copy[i][51])+"', '"+str(copy[i][52])+"', '"+str(copy[i][53])+"', '"+str(copy[i][54])+"', '"+str(copy[i][55])+"', '"+str(copy[i][56])+"', '"+str(copy[i][57])+"', '"+str(copy[i][58])+"', '"+str(copy[i][59])+"', '"+str(copy[i][145])+"', '"+str(copy[i][164])+"','False', '"+str(copy[i][88])+"', '"+str(copy[i][115])+"', '"+str(copy[i][60])+"', '"+str(copy[i][61])+"', '"+str(copy[i][62])+"', '"+str(copy[i][63])+"', '"+str(copy[i][64])+"', '"+str(copy[i][66])+"', '"+str(copy[i][71])+"', '"+str(copy[i][72])+"', '"+str(copy[i][73])+"', '"+str(copy[i][46])+"', '"+str(copy[i][67])+"', '"+str(copy[i][65])+"', '"+str(copy[i][47])+"', '"+str(copy[i][49])+"','','', '"+str(copy[i][75])+"');")
|
||
pastereq = ("INSERT INTO vcatalog.hebergement values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"','00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"', '', '"+str(copy[i][9])+"', '"+str(copy[i][12])+"', '"+str(copy[i][13])+"', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][17])+"', '"+str(copy[i][18])+"', '', '', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][21])+"', '', '', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"','"+str(villes[villenum][27])+"', '"+str(villes[villenum][13])+"','"+str(villes[villenum][19])+"', '"+str(copy[i][24])+"', '"+str(copy[i][76])+"', '"+str(copy[i][77])+"','', '"+str(copy[i][25])+"', '"+str(copy[i][26])+"', '"+str(copy[i][27])+"', '"+str(copy[i][28])+"','False', '"+str(copy[i][30])+"', '"+str(copy[i][29])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][34])+"', '"+str(copy[i][35])+"', '"+str(copy[i][36])+"', '"+str(copy[i][37])+"', '"+str(copy[i][38])+"', '"+str(copy[i][39])+"', '"+str(copy[i][40])+"', '"+str(copy[i][41])+"', '"+str(copy[i][42])+"', '"+str(copy[i][43])+"', '"+str(copy[i][44])+"', '"+str(copy[i][45])+"','False', '"+str(copy[i][50])+"', '"+str(copy[i][51])+"', '"+str(copy[i][52])+"', '"+str(copy[i][53])+"', '"+str(copy[i][54])+"', '"+str(copy[i][55])+"', '"+str(copy[i][56])+"', '"+str(copy[i][57])+"', '"+str(copy[i][58])+"', '"+str(copy[i][59])+"', 'False', 'False','False', 'False', 'False', '"+str(copy[i][60])+"', '"+str(copy[i][61])+"', '"+str(copy[i][62])+"', '"+str(copy[i][63])+"', '"+str(copy[i][64])+"', '"+str(copy[i][66])+"', '"+str(copy[i][71])+"', '"+str(copy[i][72])+"', '"+str(copy[i][73])+"', '"+str(copy[i][46])+"', '"+str(copy[i][67])+"', '"+str(copy[i][65])+"', '"+str(copy[i][47])+"', '"+str(copy[i][49])+"','','', '"+str(copy[i][75])+"');")
|
||
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def prod_avv():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM production.avv;"
|
||
cpy=query_old(copyreq)
|
||
|
||
print(len(cpy))
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
villes="SELECT * FROM vmap.ville;"
|
||
villes=query_new(villes)
|
||
|
||
services="SELECT * FROM production.type_service;"
|
||
services=query_old(services)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
villenum=-1
|
||
|
||
for j in range(len(villes)):
|
||
if str(copy[i][40])==str(villes[j][1]):
|
||
if len(str(villes[j][12]))<=10:
|
||
villenum=j
|
||
break;
|
||
|
||
servicenum=-1
|
||
|
||
for j in range(len(services)):
|
||
if str(copy[i][39])==str(services[j][1]):
|
||
servicenum=j
|
||
break;
|
||
|
||
|
||
|
||
if villenum==-1:
|
||
pastereq = ("INSERT INTO vcatalog.avv values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"', '', '"+str(copy[i][9])+"', '"+str(copy[i][13])+"', '"+str(copy[i][12])+"', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][18])+"', '"+str(copy[i][17])+"', '"+str(copy[i][19])+"', '"+str(copy[i][21])+"', '"+str(copy[i][20])+"', '"+str(copy[i][22])+"','codvil','', '"+str(copy[i][53])+"', '"+str(copy[i][54])+"','False', '"+str(copy[i][23])+"', '"+str(copy[i][26])+"','False', '"+str(copy[i][28])+"', '"+str(copy[i][27])+"', '"+str(copy[i][30])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][23])+"', '"+str(copy[i][24])+"', '"+str(copy[i][29])+"', '"+str(copy[i][33])+"', 'typeserv', '"+str(copy[i][34])+"', '"+str(copy[i][55])+"', '"+str(copy[i][56])+"', '"+str(copy[i][57])+"', '"+str(copy[i][40])+"', '"+str(copy[i][41])+"', '"+str(copy[i][42])+"', '"+str(copy[i][43])+"', '"+str(copy[i][45])+"', '"+str(copy[i][47])+"', '"+str(copy[i][48])+"', '"+str(copy[i][49])+"', '"+str(copy[i][50])+"', '"+str(copy[i][51])+"', '"+str(copy[i][58])+"');")
|
||
else:
|
||
pastereq = ("INSERT INTO vcatalog.avv values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"', '', '"+str(copy[i][9])+"', '"+str(copy[i][13])+"', '"+str(copy[i][12])+"', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][18])+"', '"+str(copy[i][17])+"', '"+str(copy[i][19])+"', '"+str(copy[i][21])+"', '"+str(copy[i][20])+"', '"+str(copy[i][22])+"','"+str(villes[villenum][13])+"','', '"+str(copy[i][53])+"', '"+str(copy[i][54])+"','False', '"+str(copy[i][23])+"', '"+str(copy[i][26])+"','False', '"+str(copy[i][28])+"', '"+str(copy[i][27])+"', '"+str(copy[i][30])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][23])+"', '"+str(copy[i][24])+"', '"+str(copy[i][29])+"', '"+str(copy[i][33])+"', '"+str(services[servicenum][6])+"', '"+str(copy[i][34])+"', '"+str(copy[i][55])+"', '"+str(copy[i][56])+"', '"+str(copy[i][57])+"', '"+str(copy[i][40])+"', '"+str(copy[i][41])+"', '"+str(copy[i][42])+"', '"+str(copy[i][43])+"', '"+str(copy[i][45])+"', '"+str(copy[i][47])+"', '"+str(copy[i][48])+"', '"+str(copy[i][49])+"', '"+str(copy[i][50])+"', '"+str(copy[i][51])+"', '"+str(copy[i][58])+"');")
|
||
|
||
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def prod_tour():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM production.tour;"
|
||
cpy=query_old(copyreq)
|
||
|
||
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
villes="SELECT * FROM vmap.ville;"
|
||
villes=query_new(villes)
|
||
|
||
services="SELECT * FROM production.type_service;"
|
||
services=query_old(services)
|
||
|
||
refs=[]
|
||
|
||
print(len(cpy[0]))
|
||
print(len(villes[0]))
|
||
print(len(services[0]))
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
villenum=-1
|
||
|
||
for j in range(len(villes)):
|
||
if str(copy[i][40])==str(villes[j][1]):
|
||
if len(str(villes[j][12]))<=10:
|
||
villenum=j
|
||
break;
|
||
|
||
servicenum=-1
|
||
|
||
for j in range(len(services)):
|
||
if str(copy[i][39])==str(services[j][1]):
|
||
servicenum=j
|
||
break;
|
||
|
||
|
||
valid=True
|
||
|
||
for j in range(len(refs)):
|
||
if str(copy[i][12])==str(refs[j]):
|
||
valid=False
|
||
break;
|
||
|
||
#if len(str(copy[i][1]))!=36:
|
||
# valid=False
|
||
|
||
|
||
if valid==True:
|
||
if villenum==-1:
|
||
pastereq = ("INSERT INTO vcatalog.tour values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][9])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"','', '"+str(copy[i][13])+"', '"+str(copy[i][12])+"','typeservice','codevil','"+str(copy[0][40])+"','', '"+str(copy[i][14])+"','"+str(copy[0][40])+"', '"+str(copy[i][15])+"', '"+str(copy[i][17])+"', '"+str(copy[i][18])+"', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][21])+"', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"', '"+str(copy[i][24])+"', '"+str(copy[i][25])+"', '"+str(copy[i][26])+"', '"+str(copy[i][27])+"', '"+str(copy[i][28])+"', '"+str(copy[i][29])+"', '"+str(copy[i][30])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][33])+"', '"+str(copy[i][34])+"', '"+str(copy[i][35])+"', '"+str(copy[i][36])+"', '"+str(copy[i][16])+"', '"+str(copy[i][37])+"', '"+str(copy[i][38])+"','True','True');")
|
||
else:
|
||
pastereq = ("INSERT INTO vcatalog.tour values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][9])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"','', '"+str(copy[i][13])+"', '"+str(copy[i][12])+"','"+str(services[servicenum][6])+"','"+str(villes[villenum][12])+"','"+str(copy[i][40])+"','"+str(copy[i][40])+"', '"+str(copy[i][14])+"','', '"+str(copy[i][15])+"', '"+str(copy[i][17])+"', '"+str(copy[i][18])+"', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][21])+"', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"', '"+str(copy[i][24])+"', '"+str(copy[i][25])+"', '"+str(copy[i][26])+"', '"+str(copy[i][27])+"', '"+str(copy[i][28])+"', '"+str(copy[i][29])+"', '"+str(copy[i][30])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][33])+"', '"+str(copy[i][34])+"', '"+str(copy[i][35])+"', '"+str(copy[i][36])+"', '"+str(copy[i][16])+"', '"+str(copy[i][37])+"', '"+str(copy[i][38])+"','True','True');")
|
||
|
||
refs.append(copy[i][12])
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def prod_guide():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM production.guide;"
|
||
cpy=query_old(copyreq)
|
||
|
||
print(len(cpy))
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO vcatalog.guide values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"','00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"','', '"+str(copy[i][9])+"', '"+str(copy[i][13])+"', '"+str(copy[i][12])+"', '"+str(copy[i][16])+"', '"+str(copy[i][18])+"', '"+str(copy[i][19])+"', '"+str(copy[i][21])+"','', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"','codvil', '"+str(copy[i][24])+"', '"+str(copy[i][23])+"','01-Sep-1983','01-Sep-1983', '"+str(copy[i][22])+"');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def prod_image():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM production.image;"
|
||
cpy=query_old(copyreq)
|
||
|
||
print(len(cpy))
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO vcatalog.image values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"', '"+str(copy[i][5])+"','00:00:00.000', '"+str(copy[i][6])+"', '"+str(copy[i][9])+"', '"+str(copy[i][7])+"','', '"+str(copy[i][10])+"', '"+str(copy[i][41])+"', '"+str(copy[i][2])+"', '"+str(copy[i][42])+"', '"+str(copy[i][13])+"', '"+str(copy[i][14])+"', '"+str(copy[i][15])+"', '"+str(copy[i][16])+"', '"+str(copy[i][18])+"', '"+str(copy[i][17])+"', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][21])+"', '"+str(copy[i][22])+"', '"+str(copy[i][23])+"', '"+str(copy[i][24])+"', '"+str(copy[i][25])+"', '"+str(copy[i][26])+"', '"+str(copy[i][27])+"', '"+str(copy[i][28])+"', '"+str(copy[i][29])+"', '"+str(copy[i][30])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"', '"+str(copy[i][33])+"', '"+str(copy[i][34])+"', '"+str(copy[i][35])+"', '"+str(copy[i][36])+"', '"+str(copy[i][37])+"', '"+str(copy[i][38])+"', '"+str(copy[i][39])+"');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def prod_prix():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM production.prix;"
|
||
cpy=query_old(copyreq)
|
||
|
||
print(len(cpy))
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO vcatalog.hebergprix values('"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"', '"+str(copy[i][4])+"','00:00:00.000', '"+str(copy[i][5])+"', '"+str(copy[i][8])+"', '"+str(copy[i][6])+"','', '"+str(copy[i][9])+"', '"+str(copy[i][18])+"', '"+str(copy[i][12])+"','', '"+str(copy[i][19])+"', '"+str(copy[i][24])+"', '"+str(copy[i][35])+"', '"+str(copy[i][13])+"', '"+str(copy[i][15])+"', '"+str(copy[i][14])+"', '"+str(copy[i][16])+"', '"+str(copy[i][21])+"','','devise','devisetaux','','', '"+str(copy[i][17])+"', '"+str(copy[i][24])+"', '"+str(copy[i][25])+"','','', '"+str(copy[i][33])+"','','','','', '"+str(copy[i][34])+"', '"+str(copy[i][36])+"', '"+str(copy[i][29])+"', '"+str(copy[i][30])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"','','');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def pack_pack():
|
||
#requete select dans l'ancienne base
|
||
copyreq="SELECT * FROM pack.pack;"
|
||
cpy=query_old(copyreq)
|
||
|
||
print(len(cpy))
|
||
|
||
copy=remplacer_apostrophe(cpy)
|
||
|
||
|
||
#ici on parcours touts les rows du select pour les transmettre ligne par ligne dans une boucle for
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO pack.pack values('"+i+"', '"+str(copy[i][0])+"', '"+str(copy[i][1])+"', '"+str(copy[i][2])+"', '"+str(copy[i][3])+"','00:00:00.000', '"+str(copy[i][4])+"', '"+str(copy[i][8])+"', '"+str(copy[i][7])+"', '"+str(copy[i][5])+"','', '"+str(copy[i][11])+"','', '"+str(copy[i][12])+"', '"+str(copy[i][16])+"', '"+str(copy[i][14])+",'', '"+str(copy[i][13])+"', '"+str(copy[i][17])+"', '"+str(copy[i][15])+"','', '"+str(copy[i][19])+"', '"+str(copy[i][20])+"', '"+str(copy[i][31])+"', '"+str(copy[i][32])+"');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
def ogfiche_clients():
|
||
|
||
#ici on ouvre le fichier csv et on le place dans une liste a l'aide du module csv
|
||
with open('clients.csv',encoding='ISO-8859-1',newline='') as f:
|
||
reader = csv.reader(f)
|
||
copy = list(reader)
|
||
|
||
copy=remplacer_apostrophe(copy)
|
||
|
||
#print(copy)
|
||
for i in range(len(copy)):
|
||
|
||
pastereq = ("INSERT INTO ogfiche.f41clients values('"+str(copy[i][1])+"','"+str(uuid.uuid4())+"','"+str(copy[i][3])+"','1983-09-01','1983-09-01','00:00:00.000','','','1983-09-01','"+str(copy[i][25])+"','GROUP','REFFIC','"+str(i)+"','False','"+str(copy[i][4])+"','"+str(copy[i][5])+"','"+str(copy[i][6])+"','"+str(copy[i][7])+"','"+str(copy[i][10])+' '+str(copy[i][11])+"','"+str(copy[i][16])+"','"+str(copy[i][13])+"','"+str(copy[i][14])+"','"+str(copy[i][17])+"','"+str(copy[i][18])+"','"+str(copy[i][19])+"','','"+str(copy[i][21])+"','','','','False','False','CSPF','"+str(copy[i][10])+' '+str(copy[i][11])+"','"+str(copy[i][16])+"','"+str(copy[i][13])+"','"+str(copy[i][14])+"','','"+str(copy[i][10])+' '+str(copy[i][11])+"','"+str(copy[i][16])+"','"+str(copy[i][13])+"','"+str(copy[i][14])+"','','','','"+str(copy[i][24])+"','1983-09-01','1983-09-01','','False','False','False','','','1983-09-01','','','','"+str(copy[i][17])+"','','','False','','1983-09-01','False');")
|
||
execute_new(pastereq)
|
||
db_conn_new.commit()
|
||
#print(copy[i][0])
|
||
|
||
|
||
|
||
|
||
#map_pays()
|
||
#map_regions()
|
||
#map_ville()
|
||
|
||
#map_dest()
|
||
#map_gateway()
|
||
#map_zlienregvilles() /!\DROITS REFUSéS/!\
|
||
#map_zlienregiondest()
|
||
|
||
#og_ej()
|
||
#og_oggroup()
|
||
#og_ogstaff()
|
||
#og_ogmodule()
|
||
|
||
#prod_avv()
|
||
#prod_hebergement()
|
||
|
||
#prod_tour()
|
||
#prod_guide()
|
||
#prod_image()
|
||
#prod_prix()
|
||
|
||
|
||
#ogc_ecrit()
|
||
#ogc_journaux()
|
||
|
||
#pack_pack()
|
||
|
||
|
||
ogfiche_clients() |