У меня есть запрос SQL, который предоставляет мне приведенный ниже выход: < /p>
Select FirstName, LastName, Title
From Default.Name
< /code>
Tony Gonzalez Mr
Tom Brady Mr
Patricia Carroll Miss
< /code>
I would like to store FirstName, LastName & title column output rows as variable so i can use these variables as an input to my API data call which would take the names and return me with the data
My API Call looks something like this: ( Ignore the format & coding as this is a test code the actual code i have works fine)
from zeep import Client
from zeep.transports import Transport
from requests import Session
from requests.auth import HTTPBasicAuth
from pyspark.sql.types import StructType, StructField, StringType, BooleanType
from pyspark.sql.functions import lit
from datetime import datetime
wsdl_url = "Test.xml"
session = Session()
session.auth = HTTPBasicAuth('abc','password')
transport = Transport(session=session)
client = Client(wsdl=wsdl_url, transport=transport)
# List all available services and ports
print(client.wsdl.services)
# Ensure the service and port names are correct
service_name = 'Test'
port_name = 'TestPort'
# Verify the available services and ports
for service in client.wsdl.services.values():
print(f"Service: {service.name}")
for port in service.ports.values():
print(f" Port: {port.name}")
# Bind to the correct service and port
service = client.bind("Test", "BasicHttpBinding_TestService")
request_data = {
'userAuth': {
'Nickname':"Test"
},
'requestReference': 'test',
'request': {
'Subject': {
'Forename': 'Patricia',
'Surname': 'Carroll'
},
'Address': {
'AddressLine1': '123 Test Street',
'AddressLine2': '',
'AddressLine3': 'LONDON',
'Postcode': 'ABC 123'
},
'ConsentFlag': True
}
}
if service:
response = service.PerformIDCheckV2(**request_data)
# Define the schema explicitly
schema = StructType([
StructField("FirstName", StringType(), True),
StructField("SurName", StringType(), True),
StructField("response", StringType(), True),
StructField("ETLApplyDateTime", StringType(), True)
])
< /code>
We can see above where i have hardcoded Patricia Name, i want those names to be passed as input from the above sql output
Подробнее здесь: https://stackoverflow.com/questions/794 ... meters-for
Как сохранить вывод SQL -запроса в качестве переменных, которые будут использоваться в качестве параметров для вызова да ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение