Skip to content

Python 3 Advantage database interface

License

Notifications You must be signed in to change notification settings

marcogiusti/adsdb3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adsdb3

Python 3 Advantage database interface

Disclaimer

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.

Install

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.

Test

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

Programming

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())

Connection options

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

About

Python 3 Advantage database interface

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published