title: Is it possible to pass in Table-Valued Parameters to PYODBC query?
body: <p>I know I can pass a TVP to a stored procedure (as it's a question I've asked here before). I'm wondering now if this is something I can do in Python. I keep on getting this error. It's saying there's an invalid type, so would the parameter need to know what type I'm passing in?</p>
  <blockquote>
  <p>pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Column, parameter, or variable #1: Cannot find data type READONLY. (2715) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Must declare the table variable &quot;@P1&quot;. (1087); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Parameter or variable '@P1' has an invalid data type. (2724)')</p>
  </blockquote>
  <pre><code>from src.data.dbaccess import con
  
  queryString2 = &quot;&quot;&quot; 
  
  SET NOCOUNT ON
  
  DECLARE @t As Table(
  PersonName VARCHAR(50)
  )
  
  INSERT INTO @t
  SELECT *
  FROM ?
  
  SELECT * FROM @t
  &quot;&quot;&quot;
  
  data = ([('Jim', ), ('Bob', )],)
  
  with pyodbc.connect(con.conString) as testCon:
      crsr = testCon.execute(queryString2, data)
      for row in crsr:
          print(row)
  </code></pre>
  <p>** Edit to clarify. In my question last year, I asked if a I could pass a TVP to a SQL Server stored procedure. This time, the procedure is being natively my Python code. This is the issue I'm trying to address now.</p>