I am not affiliated with SAP SE and this driver is not the official ADS Python driver.
This driver is still in alpha quality tho yet usable for simply tasks.
Most notably the callproc()
does not support the output parameters.
adsdb3 itself is installable with pip. If a wheel file exists for your
architecture and OS, you do not require a compiler and any header file.
Otherwise be sure to install a compiler and the header files for your
python version. In Debian, for instance, you need to install the
build-essential
and python3-dev
packages.
At runtime adsdb3 requires the Advantage Client Engine. Be sure that
the library libace.so
could be find by the linker.
adsdb2 include few test. test/test_dbapi20_adsdb3.py
uses
test/dbapi20.py
from Stuart Bishop to check the compatibility
with the Database API Specification v 2.0. To run them you need
access to a server and set either ADSDB3_DATASOURCE or
ADSDB3_CONNECTION_STRING environment variables. ADSDB3_DATASOURCE is
used only to set the DataSource connection paramenter along with few
defaults. With ADSDB3_CONNECTION_STRING you have control of the exact
connection string. See Connection options for more info. If you
don't set any of those variables, the tests that involve the server are
skipped.
You have many options to run the tests. Most likely the easier is using tox:
$ tox -e py35-nocov
adsdb3 is a DB-API2 compliant driver and it does not differ from many other drivers. The tests are a useful source of examples. Just two important notes apply here:
- always close the connections;
- always close the cursors.
Ex:
from contextlib import closing with closing(adsdb3.connect(**params)) as connection: with closing(connection.cursor()) as cursor: cursor.execute("EXECUTE PROCEDURE sp_mgGetInstallInfo();") print(*cursor.fetchone())
There is online some example of connection strings for Sybase
Advantage. The official documentation has a list of supported
options for the AdsConnect101
API, but not all them works with the
connection string. I have still to figure out which work and which do
not. Following a list of known working connection options:
- CharType
- CommType
- DataSource
- Exact
- FIPS
- ReadOnly
- ServerType
- TrimTrailingSpaces