Data exchange between Delphi and Python (Win)

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Jan 29 23:08:45 CET 2010


En Thu, 28 Jan 2010 05:07:00 -0300, Durumdara <durumdara at gmail.com>  
escribió:

> I have an exotic db, with exotic drivers, and it have buggy  ODBC driver.
>
> But I have native driver - under Delphi.
>
> I need to access this DB under Pylons (or mod_python).
> [...]
> I think to COM/OLE, because it is accessable from all program, and I  
> think
> to DLL (but DLL have problematic parameterisation).

So, you can query the database in Delphi, and you want to be able to do  
that from Python.

Your two ideas are feasible: you may write a DLL (or a COM object) in  
Delphi, that takes a query string, executes it, and returns the resulting  
data. All in Delphi code, no Python involved. Keep the memory allocation  
in Delphi - allocate and return a plain PChar buffer, and include a free()  
function to deallocate it when the other side is done using it.

 From Python, you may use ctypes [1] to call the DLL functions, or pywin32  
[2] to invoke the COM object. Both ways are easy enough.

[1] http://docs.python.org/library/ctypes.html
[2] http://sourceforge.net/projects/pywin32/

-- 
Gabriel Genellina




More information about the Python-list mailing list