简体   繁体   中英

Can you pass table input parameter to SQL Server from Python

MS SQL Server supports passing a table as a stored-procedure parameter. Is there any way to utilize this from Python, using PyODBC or pymssql?

There may be a way to do so using a more API-ey feature, but if all else fails you could just use whatever the API exposes to send raw SQL commands to build the tables yourself and call the procedure, using a query string like the following:

DECLARE @p1 <TableTypeName>;
INSERT @p1 VALUES (<value list...>);    
EXEC usp_Procedure @p1;

Use IronPython. It allows direct access to the .net framework, and therefore you can build a DataTable object and pass it over.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM