
Szenario Architecture
Connection Flow
FROM opensuse/leap:15.3
RUN zypper --non-interactive update
RUN zypper --non-interactive install --no-recommends --force-resolution python39 python39-pip git # Install python3, pip3, git
# install sql server odbc driver
RUN zypper install -y curl
RUN curl -O https://packages.microsoft.com/keys/microsoft.asc
RUN rpm --import microsoft.asc
RUN zypper ar https://packages.microsoft.com/config/sles/15/prod.repo
RUN ACCEPT_EULA=Y zypper install -y msodbcsql17
# add vflow user
RUN groupadd -g 1972 vflow && useradd -g 1972 -u 1972 -m vflow
USER 1972:1972
WORKDIR /home/vflow
ENV HOME=/home/vflow
# install additional python packages as usual
RUN python3.9 -m pip --no-cache-dir install 'pyodbc' --user
{
"pythonsqlserverodbc": "",
"python36": "",
"tornado": "5.0.2"
}
Custom Operator on Python3 basis
import pyodbc
sqlserver_connection = api.config.http_connection
api.logger.info(str(sqlserver_connection))
def connect_sqlserver():
# use pyodbc with the driver name of choice
driver_name = "ODBC Driver 17 for SQL Server"
host = sqlserver_connection["connectionProperties"]["host"]
port = sqlserver_connection["connectionProperties"]["port"]
server = f"{host},{port}"
user = sqlserver_connection["connectionProperties"]["user"]
password = sqlserver_connection["connectionProperties"]["password"]
conn = pyodbc.connect(f"DRIVER={driver_name};SERVER={server};UID={user};PWD={password}")
# sample sql query
cur = conn.cursor()
cur.execute("SELECT GETDATE() AS CurrentTimestamp;")
for row in cur:
api.logger.info(str(row))
cur.close()
conn.close()
api.add_generator(connect_sqlserver)
{
"$schema": "http://json-schema.org/draft-06/schema#",
"$id": "http://sap.com/vflow/PythonSQLServerODBC.configSchema.json",
"type": "object",
"properties": {
"codelanguage": {
"type": "string"
},
"scriptReference": {
"type": "string"
},
"script": {
"type": "string"
},
"http_connection": {
"title": "HTTP Connection",
"description": "HTTP Connection",
"type": "object",
"properties": {
"configurationType": {
"title": "Configuration Type",
"description": "Configuration Type",
"type": "string",
"enum": [
" ",
"Configuration Manager",
"Manual"
]
},
"connectionID": {
"title": "Connection ID",
"type": "string",
"format": "com.sap.dh.connection.id"
},
"connectionProperties": {
"title": "Connection Properties",
"description": "Connection Properties",
"$ref": "http://sap.com/vflow/com.sap.dh.connections.http.schema.json",
"sap_vflow_constraints": {
"ui_visibility": [
{
"name": "configurationType",
"value": "Manual"
}
]
}
}
}
}
},
"required": [
"http_connection"
]
}
In summary, we enhance the configuration by introducing a new property called "http_connection," which points to a connection of the same type within the SAP Data Intelligence connection management application. While other connection types may be suitable, I find the HTTP connection to be a convenient way to store various types of credentials. If needed, you can even store custom JSON data in the connection manager fields to achieve your desired outcome. The HTTP connection is particularly advantageous when connecting through the SAP Cloud Connector since it supports it as a gateway type.
Create HTTP Connection to store credentials
Custom ODBC Operator in graph
(datetime.datetime(2024, 1, 13, 14, 30, 15, 790000),)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
24 | |
20 | |
20 | |
19 | |
14 | |
12 | |
10 | |
9 | |
7 | |
7 |