Below is the program to Create empty files with same names and different extensions present in a specific directory in python. Here is the code: import glob import os path = 'C:\\Users\\Test\\Documents\\2025\\August\\6 Aug\\Email\\' add_extension = ".ok" i=1 for i, filename in enumerate(glob.glob(path + '*.xml')): new_filename = filename + add_extension try: with open(new_filename, 'w') as f: pass # No content is written, so the file remains empty print(f"Empty file '{new_filename}' created successfully.") except IOError as e: print(f"Error creating file: {e}")
Below is the Python program which will show you how to connect to MariaDB. Here is the code: # Module Imports import mariadb import sys # Connect to MariaDB Platform try: conn = mariadb.connect( user="user", password="password", host="host", port=port, database="database" ) except mariadb.Error as e: print(f"Error connecting to MariaDB Platform: {e}") sys.exit(1) # Get Cursor cur = conn.cursor() try: cur.execute("show databases;") cur.execute("use test_db;") cur.execute("show tables;") for table in cur: print(table) except mariadb.Error as e: print(f"Error: {e}") # Close Connection conn.close()