Использование SQL Серверные хранимые процедуры из Python (pyodb c) Как вы обрабатываете пробелы в переменных, следуя этой теме? например,
for CustomerID,TestCode,TestResult in csv_input:
#query
query = """\
SET NOCOUNT ON;
Declare @CustomerID nvarchar(100),
@TestCode nvarchar(20),
@TestResult nvarchar(10),
exec TestData.sp_uat_TestData_Customer @CustomerID = ? , @TestCode = ?, @TestResult = ?;"""
#set the ID as per the iteration of the loop
args = (CustomerID,TestCode,TestResult,)
#execute the query above using the provided variable
cursor.execute(query,args)
# print out the data returned by the Stored Procedure
for row in cursor:
print(row)
csv_output.writerow(row)
В приведенном выше примере @TestResult будет иметь значение «Пройденный тест» в 3-м столбце файла CSV.
Я пробовал следующее, но без радости: @TestResult = '' '?' '', @TestResult = '?', @TestResult = [?] И все они дают pyodb c .ProgrammingError: ('SQL содержит 2 маркера параметров, но было передано 3 параметра' , 'HY000')
Я даже пытался добавить одинарные кавычки к значению во входном CSV и все еще не прогрессировал. Любые советы приветствуются.