To write data to a Progress database from an Excel file using Python, you can use the openpyxl
library to read the data from the Excel file and the pyodbc
library to connect to the Progress database and insert the data. Here’s a sample code:
import pyodbc from openpyxl import load_workbook # Connect to the Progress database conn = pyodbc.connect('Driver={Progress OpenEdge 10.2B driver};HOST=hostname;PORT=port;DATABASE=database_name;UID=username;PWD=password') # Load the Excel workbook workbook = load_workbook(filename='data.xlsx') # Select the worksheet worksheet = workbook['Sheet1'] # Iterate through each row in the worksheet and insert the data into the database for row in worksheet.iter_rows(values_only=True): cursor = conn.cursor() cursor.execute("INSERT INTO table_name (column1, column2, column3) VALUES (?, ?, ?)", row[0], row[1], row[2]) cursor.commit() # Close the database connection conn.close()
In this example, the Excel file data.xlsx
has data in the first three columns of Sheet1
, and the data is inserted into a table named table_name
in the Progress database. You can modify the SQL query in the cursor.execute()
method to match the columns and table structure in your database.