moved scripts to database scripts
This commit is contained in:
30
py_app/app/db_create_scripts/delet scan1_orders values.py
Normal file
30
py_app/app/db_create_scripts/delet scan1_orders values.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import mariadb
|
||||||
|
|
||||||
|
# Database connection credentials
|
||||||
|
def get_db_connection():
|
||||||
|
return mariadb.connect(
|
||||||
|
user="trasabilitate", # Replace with your username
|
||||||
|
password="Initial01!", # Replace with your password
|
||||||
|
host="localhost", # Replace with your host
|
||||||
|
port=3306, # Default MariaDB port
|
||||||
|
database="trasabilitate_database" # Replace with your database name
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Connect to the database
|
||||||
|
conn = get_db_connection()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# Delete query
|
||||||
|
delete_query = "DELETE FROM scan1_orders"
|
||||||
|
cursor.execute(delete_query)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
print("All data from the 'scan1_orders' table has been deleted successfully.")
|
||||||
|
|
||||||
|
# Close the connection
|
||||||
|
cursor.close()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
except mariadb.Error as e:
|
||||||
|
print(f"Error deleting data: {e}")
|
||||||
Reference in New Issue
Block a user