Procedure documentation Call with the Python Interface of the SAP DB Loader Locate the document in its SAP Library structure

You can call the SAP DB Loader through the processing of a Python script.

Prerequisites

The following Python modules are delivered with the SAP DB Loader program to allow you to create Python scripts that can be processed by the Structure linkLoader.

Note

These are the modules you need to use the SAP DB Loader functions. You do not need a complete PYTHON installation.

If you already have a PYTHON installation, add %INSTROOT%\misc to the PYTHONPATH variable.

The SAP DB Loader supports PYTHON as of version 1.5.2.

Call

x_python <python_script_file> [<argument>...]

You can optionally specify arguments <argument>.

Frequently used arguments:

<user_name>
<password>

User name
Password

<database_name>

Name of database instance

<data_path>

Directory in which the data file is stored

<server_node>

Name of the server on which the Loader is located

Example

X_python sample samplename secret TST C:\data\sapdb

The Python script sample is called. The logon to the Loader is performed for the user samplename on the database instance TST. The data file is in the directory C:\data\sapdb.

Template for Background Files

The following section contains examples of background files in Python. Their equivalents in the Perl script language are also provided for comparison.

Example 1
Build a Python module with reference to the SAP DB Python Libraries,
parse the call arguments


Python


Perl

Example 2
Create a database session with the Loader
Log on to the database instance
Log off



Python



Perl

Example 3
Set up a database session
Log on to the database instance
Query whether a table exists by querying the error code
Create a table without querying the error code
Log off



Python



Perl

Example 4
Create a database session
Log on to the database instance
Create a table and query the error code
Use
command(s) to load data into the table and query the error code
Log off




Python




Perl

Example 5
Create a database session
Log on to the database instance
Use command(s) to load data into table and intercept exceptions
Log off



Python



Perl

Python Classes