Python beside Delphi, not instead of it
I maintain an ERP that runs a footwear factory. It is a Delphi VCL desktop application: 488 units, roughly 160,000 lines of Object Pascal, sitting on a MySQL database of 342 tables. It handles production planning, warehouse management, shipping, inventory and sales. It has been in production for years, and the factory does not stop so that I can refactor. I am the only engineer on it. There are…
The article discusses how Python is being used alongside Delphi in a complex ERP system that manages a footwear factory. The Delphi VCL desktop application, written in Object Pascal, consists of 488 units with around 160,000 lines of code and is connected to a MySQL database with 342 tables. The author, the only engineer working on this system, has found Python to be a valuable tool for handling various aspects of the project.
Python is used for tasks that would be too risky or time-consuming to perform directly in Delphi. The schema is dumped into a JSON file, making it easier to version control and track changes over time. The Python script also parses the Delphi source code, extracting SQL queries and generating a shortcut map from keyboard shortcuts defined in form files.
This allows for a redundant implementation of functionality, where a Python script can validate changes before they are deployed, avoiding the need for a Delphi rebuild or deployment.
The article also highlights the challenges of working with a legacy codebase, particularly the use of Windows-1252 encoding for Portuguese source files. Python scripts have been written to ensure that any modifications are made using the correct CP1252 encoding to avoid introducing malformed sequences. This attention to detail helps maintain the integrity of the codebase and prevents unexpected issues during runtime.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.