Not Able To Create Database Using Stored Procedure Pyodbc Sql Server
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};S
Solution 1:
The Python DB API 2.0 specifies that, by default, connections should be opened with autocommit disabled. However, many databases require that DDL statements not be executed within a transaction. Attempts to execute DDL statements with autocommit disabled can lead to errors or unexpected results.
Therefore, it is safer to ensure that DDL statements are executed on a connection where autocommit is enabled. That can be accomplished by setting autocommit=True
when opening the connection ...
cnxn = pyodbc.connect(connection_string, autocommit=True)
... or by enabling autocommit
on an existing connection ...
cnxn = pyodbc.connect(connection_string)
# ...
cnxn.autocommit = True
Post a Comment for "Not Able To Create Database Using Stored Procedure Pyodbc Sql Server"