Using Python with Caché
The Caché Python Binding
[Back] [Next]
Go to:

The Caché Python binding provides a simple, direct way to manipulate Caché objects from within a Python application. It allows Python programs to establish a connection to a database on Caché, create and open objects in the database, manipulate object properties, save objects, run methods on objects, and run queries. All Caché datatypes are supported.

The Python binding offers complete support for object database persistence, including concurrency and transaction control. In addition, there is a sophisticated data caching scheme to minimize network traffic when the Caché server and the Python applications are located on separate machines.
This document assumes a prior understanding of Python and the standard Python modules. Caché does not include a Python interpreter or development environment.
Python Binding Architecture
The Caché Python binding gives Python applications a way to interoperate with objects contained within a Caché server. The Python binding consists of the following components:
The basic mechanism works as follows:
Quick Start
Here are examples of a few basic functions that make up the core of the Python binding:
Installation and Configuration
The standard Caché installation places all files required for Caché Python binding in <cachesys>/dev/Python. (For the location of <cachesys> on your system, see Default Caché Installation Directory in the Caché Installation Guide). You should be able to run any of the Python sample programs after performing the following installation procedures.
Python Client Requirements
Caché provides client-side Python support through the intersys.pythonbind module, which implements the connection and caching mechanisms required to communicate with a Caché server.
This module requires the following environment:
UNIX® Installation
Windows Installation
Caché Server Configuration
Very little configuration is required to use a Python client with a Caché server. The Python sample programs provided with Caché should work with no change following a default Caché installation. This section describes the server settings that are relevant to Python and how to change them.
Every Python client that wishes to connect to a Caché server needs the following information:
By default, the Python sample programs use the following connection information:
Check the following points if you have any problems:
Sample Programs
The standard Caché installation contains a set of sample programs that demonstrate the use of the Caché Python binding. These samples are located in:
(For the location of <cachesys> on your system, see Default Caché Installation Directory in the Caché Installation Guide)
The following sample programs are provided:
All of these applications use classes from the Sample package in the SAMPLES namespace (accessible in Caché Studio).
The sample programs are controlled by various switches that can be entered as arguments to the program on the command line. A default value is supplied if you don't enter an argument.
For example, accepts the following optional arguments:
A -user argument would be specified as follows:
   python -user _MYUSERNAME
The sample accepts a -query argument that is passed to an SQL query:
   python -query A
This query will list all Sample.Person records containing names that start with the letter A.