import os import pyodbc import random import string # Path to your Access database db_path = r"u:\Dropbox\!!!Days\Downloads Z230\Access\Banka.accdb" # Connection string conn_str = ( r"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};" rf"DBQ={db_path};" ) # Connect to database conn = pyodbc.connect(conn_str) # Create cursor cursor = conn.cursor() cursor.execute("delete from transactions") conn.commit() exit(0) length = 10 # desired length chars = string.ascii_letters + string.digits # A-Z, a-z, 0-9 # Example query # cursor.execute("SELECT * FROM contacts") print("Start") for n in range(10000): random_str = ''.join(random.choices(chars, k=length)) cursor.execute("insert into contacts (company) values (?)",(random_str)) print("stop") conn.commit() print("committed") exit(0) # Example query cursor.execute("SELECT * FROM contacts") rows = cursor.fetchall() for row in rows: print(row) # Close connection cursor.close() conn.close()