39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
|
|
from pycen import con_bdcen, update_to_sql
|
|
import pandas as pd
|
|
|
|
rq_prestation = "SELECT id, val_mat FROM ref_travaux.cr_valorisation_matiere"
|
|
cur = con_bdcen
|
|
cur = cur.execute(rq_prestation)
|
|
res_prestation = cur.fetchall()
|
|
dict_p = dict(res_prestation)
|
|
|
|
|
|
tab = 'cr_point_saisie_travaux'
|
|
sch = 'travaux'
|
|
c = 'val_mat'
|
|
# df = pd.read_sql_table(tab,con_bdcen,sch)
|
|
df = pd.read_sql_table(tab,con_bdcen,sch,columns=['gid',c])
|
|
|
|
df[c] = df[c].str.strip()
|
|
df[c] = df[c].replace({
|
|
'réalisé':'Réalisé',
|
|
'prévisionnel':'Prévisionnel'
|
|
})
|
|
df[c] = df[c].replace('',None)
|
|
df[c] = df[c].replace([*dict_p.values()],[*dict_p.keys()])
|
|
df[c] = df[c].astype(str)
|
|
df[c] = df[c].replace('None',None)
|
|
|
|
print(df[c].unique())
|
|
|
|
|
|
df.loc[df.prestation=='barre de coupe','prestation'] = '3'
|
|
|
|
sql = 'ALTER TABLE %s.%s DISABLE TRIGGER ALL'%(sch,tab)
|
|
with con_bdcen.begin() as cnx:
|
|
cnx.execute(sql)
|
|
update_to_sql(df,con_bdcen,tab,sch,'gid')
|
|
sql = 'ALTER TABLE %s.%s ENABLE TRIGGER ALL'%(sch,tab)
|
|
with con_bdcen.begin() as cnx:
|
|
cnx.execute(sql) |