由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - run SQL stored procedure from python
相关主题
get value returned by SQLstored procedure from python (转载)[转载] intensive I/O and odbc problem
DSN-less connection to SQL serverhow to check the definition of a stored procedure in TOAD
SQL debug step into a store procedure from another one (转载)Stored Procedure?
如何让SQL 2005 CLR Trigger返回结果给Stored Procedure用?请推荐关于Stored Procedure的书
请问怎样找到StoredProcedures的修改记录?Can I use array in SQL stored procedure?
how to link to remote access database?Help: stored procedure in oracle
create table on SQL server from python pyodbc (转载)请教:how to call a COM object in a stored procedure?
pypyodbc error access netezza SQL server on win7Stored Procedure的Is和As有什么区别,还有 ······
相关话题的讨论汇总
话题: sql话题: my话题: procedure话题: run话题: db
进入Database版参与讨论
1 (共1页)
l******9
发帖数: 579
1
I need to run a SQL server 2008 R2 stored procedure from Eclipse pydev with
python 3.2 on win 7. If I run the stored procedure from management studio,
it works well.
But, if I run it from ptython , it does not work.
sql_str_test = """
DELETE FROM [my_db].[dbo].[my_table] -- this line works
EXEC [my_db].[dbo].[my_store_procedure] -- but this line
does not work, no run-time error message, but no results generated
"""
sql_str_connect = "DRIVER={SQL server};SERVER={my_server};DATABASE={my_db};
UID=my_id;PWD=my_table"
cnxn = pyodbc.connect(sql_str_connect)
cursor_test = cnxn.cursor()
cursor_test.execute(sql_str_test)
cnxn.commit()
If I run
DELETE FROM [my_db].[dbo].[my_table]
EXEC [my_db].[dbo].[my_store_procedure]
from SSMS, it works.
Thanks
o**a
发帖数: 1315
2
貌似没问题
要看你这个SP什么功能,如果就是QUERY或者输出什么的,从PYTHON里面成功运行了但
结果不一定可见
l******9
发帖数: 579
3
Why the expected results cannot be seen ?
Also, how to access two databases in one ODBC connection from pyodbc ?
thanks !

【在 o**a 的大作中提到】
: 貌似没问题
: 要看你这个SP什么功能,如果就是QUERY或者输出什么的,从PYTHON里面成功运行了但
: 结果不一定可见

o**a
发帖数: 1315
4
试运行几个不同的sp就知道了
直接在sql string里面指明2nd db就行,比如,[2nd db].[schema].[object]

【在 l******9 的大作中提到】
: Why the expected results cannot be seen ?
: Also, how to access two databases in one ODBC connection from pyodbc ?
: thanks !

1 (共1页)
进入Database版参与讨论
相关主题
Stored Procedure的Is和As有什么区别,还有 ······请问怎样找到StoredProcedures的修改记录?
[合集] Stored Procedure的Is和As有什么区别,还有 ······how to link to remote access database?
#在SQL里啥子意思create table on SQL server from python pyodbc (转载)
改写(migrate) stored proc 问题pypyodbc error access netezza SQL server on win7
get value returned by SQLstored procedure from python (转载)[转载] intensive I/O and odbc problem
DSN-less connection to SQL serverhow to check the definition of a stored procedure in TOAD
SQL debug step into a store procedure from another one (转载)Stored Procedure?
如何让SQL 2005 CLR Trigger返回结果给Stored Procedure用?请推荐关于Stored Procedure的书
相关话题的讨论汇总
话题: sql话题: my话题: procedure话题: run话题: db