commit bc4be7f9a784824f958322243a55b4cac1e99ec6 Author: Lucia Silla Date: Fri Dec 6 17:54:09 2024 +0100 first commit diff --git a/connection.py b/connection.py new file mode 100644 index 0000000..cac59d2 --- /dev/null +++ b/connection.py @@ -0,0 +1,23 @@ +import mysql.connector +from mysql.connector import Error + +def create_connection(host_name, user_name, user_password, db_name,port): + connection = None + try: + connection = mysql.connector.connect( + host=host_name, + user=user_name, + password=user_password, + database=db_name, + port=port, + ssl_disabled=True + ) + print("Connessione al database riuscita!") + except Error as e: + print(f"Errore: {e}") + return connection + +def close_connection(connection): + if connection is not None and connection.is_connected(): + connection.close() + print("Connessione al database chiusa.") \ No newline at end of file diff --git a/insert.py b/insert.py new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py new file mode 100644 index 0000000..e69de29 diff --git a/search.py b/search.py new file mode 100644 index 0000000..0b3d421 --- /dev/null +++ b/search.py @@ -0,0 +1,27 @@ +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() + cursor_2 = connection.cursor() + query = "SELECT codice FROM art WHERE codice = %s" + cursor_1.execute(query,(codice)) + result_1 = cursor.fetchone() + + if result_1: ## se l'articolo esiste creco per codice listino + 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() + + if result_2: ## se il codice listino รจ stato trovato + return True ## esistono sia articolo che codice listino + else: + return False ## articlo esiste ma non esiste il codice listino + else: + return False ## l'articolo non esiste \ No newline at end of file diff --git a/update.py b/update.py new file mode 100644 index 0000000..e69de29