1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| import cx_Oracle
def stock_usi_to_stock_orli(taille,quantite,article,couleur):
sql= "select :quantite from prod_stok where code_lieu = 'USI' and code_art_com = :article and code_colm = :couleur and typ_enrg = '0'"
sql1= "update prod_stok set "+ taille +"= :quantite where code_art_com = :article and code_colm=:couleur and code_lieu= 'USI' and typ_enrg = '0'"
try:
with cx_Oracle.connect("user", "pass", "base_de_donnée") as connection:
with connection.cursor() as cursor:
cursor.execute(sql,[quantite,article,couleur])
connection.commit()
cursor.rowfactory = int(quantite)
quantite_initial = cursor.fetchone()
quantie_vendu = quantite_initial - quantite
cursor.execute(sql1,[quantie_vendu,article,couleur])
connection.commit()
except cx_Oracle.Error as error:
print(error)
if __name__ == '__main__':
stock_usi_to_stock_orli("qte_3",40,"184","300") |
Partager