Extension Module for Python Configuration Overview

Complete basic configuration tasks for a Python application to make a connection and execute commands.

Configuration Tasks

Configuration task include:
  • Python module search path
  • The name and address of the target server
  • Security and Directory Services
  • Runtime configuration through the ocs.cfg file

Python Module Search Path

Python searches for an imported module in the list of directories given by the Python variable sys.path. This variable is initialized from the directory containing the application, and in the list of directories specified by the environment variable PYTHONPATH, which uses the same syntax as the shell variable PATH, that is, a list of directory names. If you have not set PYTHONPATH, or if the file is not found, the search continues in an installation-dependent default path.

To use the Adaptive Server Enterprise extension module for Python in an application, you must set either PYTHONPATH, or the Python variable sys.path to one of the following directory paths (these are the default directories where the different versions of the Adaptive Server Python extension module are installed):

Platform

Default Installation Path

Python Version

Windows

$SYBASE\$SYBASE_OCS\python\python26_64\dll

2.6

$SYBASE\$SYBASE_OCS\python\python27_64\dll

2.7

$SYBASE\$SYBASE_OCS\python\python31_64\dll

3.1

All other platforms

$SYBASE/$SYBASE_OCS/python/python26_64r/lib

2.6, 2.7

$SYBASE/$SYBASE_OCS/python/python31_64r/lib

3.1

Target Server Name and Address

The name of the target server is obtained from one of these sources, in this order:
  • The client application, which can provide the server name in the call to sybpydb.connect().
  • The DSQUERY environment variable, if the application does not specify the target server.
  • The default name SYBASE, if DSQUERY is not set.

The target server’s address is obtained from the directory service or from the platform-dependent interfaces file. Create a server entry in the interfaces file or the LDAP directory service. See the Open Client and Open Server Configuration Guide for your platform.

Security and Directory Services

To change the directory driver or security driver, configure libtcl.cfg

See the Open Client and Open Server Configuration Guide for your platform.

Runtime Configuration

Use the runtime configuration file ocs.cfg to set:

See Using the Open Client and Open Server Runtime Configuration File in the Open Client Client-Library/C Reference Manual for information about the file syntax and the properties that can be set in the file.