diff --git a/0_FONCIER/grant_table.py b/0_FONCIER/grant_table.py index 9acac6a..2a5c391 100644 --- a/0_FONCIER/grant_table.py +++ b/0_FONCIER/grant_table.py @@ -1,17 +1,8 @@ -from pycen import con_bdcen,con_fon as con +from pycen import con_bdcen,con_cad,con_fon as con import geopandas as gpd from sqlalchemy import create_engine, text -user_cad = 'cgeier' # utilisateur de connexion à la bdd -pwd_cad = 'adm1n*bdCen' # mot de passe de la bdd -adr_cad = '91.134.194.221' # adresse ip de la bdd -port_cad = '5432' # port de la bdd -base_cad = 'cadastre' # nom de la bdd -schema_cad = '07_202307' -con_cad = create_engine('postgresql+psycopg2://{0}:{1}@{2}:{3}/{4}'.format(user_cad,pwd_cad,adr_cad,port_cad,base_cad), echo=False) - - def get_list_table(con,sch): return con.dialect.get_table_names(con,schema=sch) @@ -48,12 +39,14 @@ def revoke_all_table(con,sch): print('REVOKE SELECT grp_consult FOR "%s".%s'%(sch,tab)) for tab in get_list_view(con,sch): - sql = 'REVOKE SELECT ON "%s".%s TO grp_consult;'%(sch,tab) + sql = 'REVOKE SELECT ON "%s".%s FROM grp_consult;'%(sch,tab) with con.begin() as cnx: cnx.execute(sql) print('REVOKE SELECT TO grp_consult FOR "%s".%s'%(sch,tab)) if __name__ == "__main__": - grant_all_table(con_cad,schema_cad) - # revoke_all_table(con,base_cad) \ No newline at end of file + sch_cad = '42_202407' + sch_old = '42_202207' + grant_all_table(con_cad,sch_cad) + # revoke_all_table(con_cad,sch_old) \ No newline at end of file