38 lines
787 B
Python
38 lines
787 B
Python
#!/usr/bin/env python3
|
|
# -*- coding:UTF-8 -*-
|
|
|
|
from sqlalchemy import create_engine #, text
|
|
from sqlalchemy.engine import URL
|
|
import pandas as pd
|
|
|
|
|
|
# Parametres bdd
|
|
user = 'cen_admin'
|
|
pwd = '#CEN38@venir'
|
|
adr = '91.134.194.221'
|
|
port = '5432'
|
|
base = 'sicen2'
|
|
|
|
url = URL.create('postgresql+psycopg2',
|
|
username=user,
|
|
password=pwd,
|
|
host=adr,
|
|
database=base,
|
|
)
|
|
con = create_engine(url)
|
|
|
|
sql = '''
|
|
SELECT * FROM inpn.taxons_isere_absents_taxref
|
|
WHERE cd_nom::text NOT IN (SELECT cd_nom FROM inpn.taxref)'''
|
|
taxabs = pd.read_sql_query(
|
|
sql=sql,con=con
|
|
)
|
|
taxabs.cd_ref = taxabs.cd_ref.astype(int).astype(str)
|
|
taxabs.drop(columns=['id_taxon','source'], inplace=True)
|
|
taxabs.to_sql(
|
|
name='taxref',
|
|
con=con,
|
|
schema='inpn',
|
|
if_exists='append',
|
|
index=False
|
|
) |