0

I have the following function

def retrieve_metadata(self, sample_name, workflow_execution_id):
 print("Starting to retrieve meta data from Workflow for Sample {} and WorkflowExection {}".format(
 sample_name, workflow_execution_id))
 sql_query = """SELECT s.SampleName, s.ClientSampleId, s.ClientSubjectId, p.ProjectName, c.ClientName, s.ProjectId, e.WorkflowExecutionId from Sample s join project p on s.ProjectId = p.ProjectId join Client C on p.ClientId = c.ClientId left join SampleExecution e on e.SampleId = s.SampleId where s.SampleName = %s and e.WorkflowExecutionId = %s"""
 package_data = (sample_name, workflow_execution_id)
 for row in self.sql_reader.cursor.execute(sql_query, package_data):
 temp_meta = MetaData(row.SampleName,
 row.ClientSampleId,
 row.ClientSubjectId,
 row.ProjectName,
 row.ClientName,
 row.ProjectId,
 row.WorkflowExecutionId,
 )
 self.input_data.append(temp_meta)

I recently changed the code to accept the parameters, but the error I am getting is

 File "/var/task/sql_scrapper.py", line 21, in retrieve_metadata
 for row in self.sql_reader.cursor.execute(sql_query, package_data):
ProgrammingError: ('The SQL contains 0 parameter markers, but 2 parameters were supplied', 'HY000')

How can I resolve this with PYODBC?

asked Dec 6, 2018 at 19:11

1 Answer 1

1
 sql_query = """SELECT s.SampleName, s.ClientSampleId, s.ClientSubjectId, p.ProjectName, c.ClientName, s.ProjectId, e.WorkflowExecutionId from Sample s join project p on s.ProjectId = p.ProjectId join Client C on p.ClientId = c.ClientId left join SampleExecution e on e.SampleId = s.SampleId where s.SampleName = ? and e.WorkflowExecutionId = ?"""

changing from %s to ? resolved the issue.

answered Dec 6, 2018 at 19:19
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.