New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyodbc supports queries with table valued parameters in sql server? #290
Comments
TVPs require access to descriptor fields (IPD/APD), which pyODBC currently does not support. |
An update: @v-chojas and his team has expressed a desire to have pyodbc support this. We don't have a time frame yet. |
@v-chojas Thanks for finding the duplicate. Since it has been asked again, can we clarify if you think this is something that should be added and if you and your team are considering working on this? I can't find any notes on this. Otherwise we should update this and close it. |
@mkleehammer Yes, we were planning on adding TVP and had done some preliminary design and investigation but other things (the attempted merging of fast_executemany, etc.) took priority. Now that the latter seems to have calmed down, we can resume working on TVP. |
I am trying to execute a table value function with parameters in python. As follows. The query does not work as pyodbc seems to recognize the parameter values as column names. Not sure if this related to the above. Can I do this with pyodbc?, it seems to me it is nothing more than execution of a query. sqlquery = select * from getsomething(?, ?) |
@glennmschultz please open a new issue and provide an ODBC trace. TVF is different from TVP. |
(almost) a year since the last post: have you made any progress on adding TVPs to pyodbc? |
It has been implemented: #488 |
Can you please give an example/ sample implementation about how to use it? |
@Lijo-CheeranJoseph - See the example in the tests. |
@gordthompson Do I have to duplicate that string along each row in the params? I am getting this error where my second parameter is a TVP with a uniqueidentifier and float value |
No. # a table-valued parameter is a list of tuples
tvp_data = [("4FE34A93-E574-04CC-200A-353F0D1770B1", 1.23),
("33F7504C-2BAC-1B83-01D1-7434A7BA6A17", 3.14),]
# parameter values for .execute() are a tuple
params_for_execute = ("my string value", tvp_data)
# --------+-------- ----+---
# | |
# a simple string --+ +-- a list of tuples
crsr.execute("{CALL my_sp (?, ?)}", params_for_execute) |
@mkleehammer - I think we can close this now. |
Still I am getting the same error
Have explained this in detail in this issue : #732 |
Environment
Issue
I'm searching for a way to use a table valued parameter when quering a Sql Server 2017 database from python. Is it possible with pyodbc?
The text was updated successfully, but these errors were encountered: