1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| # coding: utf-8
import cx_Oracle
import os.path
import os
import datetime
import os.path, time
import shutil
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email import encoders
def requete_to_stock_USI(taille,article,couleur):
#Nous créeons notre requête SQL ici
sql= "SELECT * FROM prod_stok where QTE_"+ taille +" = 0 and code_art_com =:article and code_colm=:couleur and code_lieu= 'USI' and typ_enrg = '0'"
try:
#Connexion à la base de donnée
with cx_Oracle.connect("user", "user", "base de donnée") as connection:
with connection.cursor() as cursor:
#Nous excutons la requête ici
cursor.execute(sql,[article,couleur])
with open('alert.txt','w+') as file:
for row in cursor:
file.write(str(row))
file.close()
#Cette partie de code nous renvois les erreurs de la requête s'il y en a.
except cx_Oracle.Error as error:
print(error)
def alert_to_stock_USI():
liste_best_articles ={'0018':'300','0046':'300','5046':'300','0004':'300'}
for i,k in liste_best_articles.items():
for y in range(12):
if y > 1:
alert = requete_to_stock_USI(str(y),i,k) |
Partager