48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
import pandas as pd
|
|
import mysql.connector
|
|
import math
|
|
import xlsxwriter
|
|
import tkinter as tk
|
|
from tkinter import filedialog,messagebox
|
|
from datetime import datetime
|
|
from mysql.connector import Error
|
|
|
|
def search_article(connection, codice, listino):
|
|
cursor_1 = connection.cursor(buffered=True)
|
|
cursor_2 = connection.cursor(buffered=True)
|
|
query_executed_cursor_2 = False # Variabile per controllare se la query è stata eseguita
|
|
try:
|
|
query = "SELECT codice FROM art WHERE codice = %s"
|
|
cursor_1.execute(query, (codice,))
|
|
result_1 = cursor_1.fetchone()
|
|
|
|
if result_1: # se l'articolo esiste
|
|
query_lsv = "SELECT TLV_CODICE FROM lsv WHERE ART_CODICE = %s AND TLV_CODICE = %s"
|
|
cursor_2.execute(query_lsv, (codice, listino))
|
|
result_2 = cursor_2.fetchone()
|
|
query_executed_cursor_2 = True
|
|
|
|
if result_2:
|
|
print('codice listino trovato')
|
|
return True
|
|
else:
|
|
print('codice listino non trovato')
|
|
return 'not code art'
|
|
else:
|
|
print('codice non esiste')
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"Errore durante la ricerca: {e}")
|
|
return None
|
|
|
|
finally:
|
|
|
|
if cursor_1:
|
|
cursor_1.close()
|
|
if cursor_2 and query_executed_cursor_2:
|
|
cursor_2.fetchall()
|
|
cursor_2.close()
|
|
|
|
|