Here’s a sample code in Python to write data to a Progress database using the pyodbc library
import pyodbc # Set up the connection to the Progress database conn = pyodbc.connect('DRIVER={Progress OpenEdge 10.2A Driver};HOST=<your host>;PORT=<port number>;DB=<database name>;UID=<username>;PWD=<password>') # Set up a cursor to execute SQL queries cursor = conn.cursor() # Define the SQL query to insert data into a table sql_query = "INSERT INTO my_table (column1, column2, column3) VALUES (?, ?, ?)" # Define the data to be inserted data = [ ('value1', 'value2', 'value3'), ('value4', 'value5', 'value6'), ('value7', 'value8', 'value9') ] # Execute the SQL query for each row of data for row in data: cursor.execute(sql_query, row) # Commit the changes to the database conn.commit() # Close the connection conn.close()
In this example, we first set up a connection to the Progress database using the pyodbc
library. We then define a cursor to execute SQL queries, and define an SQL query to insert data into a table. We also define the data to be inserted as a list of tuples.
We then loop through the data and execute the SQL query for each row using the cursor. Finally, we commit the changes to the database and close the connection.