I am trying to call a stored procedure that creates a Database from pyodbc
The Following is a minimal example of the code
import pyodbc
conn = pyodbc.connect("Driver={SQL Server};Server=SERVERNAME;Trusted_Connection=yes;")
cursor=conn.cursor()
cursor.execute("""\
DECLARE @RC int
DECLARE @ClientName varchar(255)
SET @ClientName = 'Test'
EXECUTE @RC = [DB_NAME].[SCHEMA].[sp_NAME] @ClientName
""")
conn.commit()
The code should ideally create a Database named 'Test' in the SQL Server Instance. This does not produce any error. But the database is not created.
Running
DECLARE @RC int
DECLARE @ClientName varchar(255)
SET @ClientName = 'Test'
EXECUTE @RC = [DB_NAME].[SCHEMA].[sp_NAME] @ClientName
From SSMS seems to create the database. Already referred a couple of questions including this one.