Tuesday, 15 September 2015

A Python API for Pyrrho

As of today, OSPLink.py is available in the distribution and enables the open-source Pyrrho server OSPSvr to be accessed from Python 3.4 clients. The API has similarities to Pyrrho’s version of ADO.NET.
To use OSPLink.py, place it in the same folder as your Python script.

(Update 30 Sept 2015: OSPLink.py now includes Python implementations of the AWebSvr classes from TAWQT.com and does not depend on .NET. There is a tutorial on the PyrrhoDB website containing a fully-worked-out sample.)

For example (assuming OSPSvr.exe is running on the local machine):

from OSPLink import *
conn = PyrrhoConnect("Files=Temp;User=Fred")
    conn.act("create table a(b date)")
except DatabaseError as e:
conn.act("insert into a values(current_date)")
com = conn.createCommand()
com.commandText = 'select * from a'
rdr = com.executeReader()
while rdr.read():

For full details, see section 6.8 of the PyrrhoDB Manual.