Let's focus on using SAP as the database engine and just doing different queries. Can I do it in Python?
Python SAP RFC module seems inactive - last (insignificant ) commit 2 years ago - but may serve you:
Pysaprfc is a wrapper around SAP librfc (librfc32.dll on Windows, librfccm.so or librfc.so on Linux). It uses the excellent ctypes extension package by Thomas Heller to access librfc and to define SAP compatible datatypes.
Modern SAP versions go the Web Service
way - you could build a SAP Web Service
and consume it from Python
.
With SAP NetWeaver, developers can connect applications and data sources to integrate processes using Web services.
In particular, developers can use one infrastructure to define, implement, and use Web services in an industry standards based way. SAP NetWeaver supports synchronous, asynchronous, stateful and stateless web service models - enabling developers to support different integration scenarios.
sapnwrfc
supports this SAP NetWeaver
functionality, supersedes the older RFC SDK, and is actively maintained.
Sap is NOT a database server. But with the Python SAP RFC module you can query most table quite easily. It is using some sap unsupported function ( that all the world is using). And this function has some limitation on field size and datatypes.
If you're talking about (what used to be named) the SAP Database AKA SapDb, and is now MaxDB (for a while distributed also by MySql Inc, now again by SAP only -- and so named SAP MaxDB), it comes with several Python access modules, documented here.
This is the only meaning I can attach to "SAP as the database engine" -- that you want to access SAP MaxDB. Other answers make different assumptions and (I believe) are also correct... under those different assumptions.
As stated above, when you just want to read tables or do RFC or BAPI calls, you can use CPython with the unmaintained Python SAP RFC module or Piers Harding's SAP RFC. The RFC calls to just read a table are RFC_GET_TABLE_ENTRIES or RFC_READ_TABLE, where the former is preferred, but also not released to customers.
For a more official way, you can use SAP's JCO connector with Jython or SAP's .Net Connector with Ironpython; both connectors can be downloaded from SAP's service marketplace and both allow to call the RFC functionality including the two calls listed above.
As also stated above, the way proposed by SAP to access backend functionality is via SAP's vast SOA infrastructure. Here you can use Jython with e.g. the Axis library or Ironpython with Microsofts WCF. Note, that the services provided by SAP obviously won't allow you to access the plain tables, instead you just can call, what a service provides. SAP already delivers about 3.000 services (see the ES Wiki on SDN), and creating your own service is in fact dead simple, once you have your business logic in a remote-enabled function module.