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 !
|
|