Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mssql_python/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def autocommit(self, value: bool) -> None:
self.setautocommit(value)
log('info', "Autocommit mode set to %s.", value)

def setautocommit(self, value: bool = True) -> None:
def setautocommit(self, value: bool = False) -> None:
"""
Set the autocommit mode of the connection.
Args:
Expand Down
2 changes: 1 addition & 1 deletion mssql_python/db_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
from mssql_python.connection import Connection

def connect(connection_str: str = "", autocommit: bool = True, attrs_before: dict = None, **kwargs) -> Connection:
def connect(connection_str: str = "", autocommit: bool = False, attrs_before: dict = None, **kwargs) -> Connection:
"""
Constructor for creating a connection to the database.

Expand Down
3 changes: 2 additions & 1 deletion tests/test_003_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import pytest
import time
from mssql_python import Connection, connect, pooling
#from pyodbc import connect, Connection, pooling

def drop_table_if_exists(cursor, table_name):
"""Drop the table if it exists"""
Expand Down Expand Up @@ -73,7 +74,7 @@ def test_connection_string_with_odbc_param(db_connection):
assert "Driver={ODBC Driver 18 for SQL Server};;APP=MSSQL-Python;Server=localhost;Uid=me;Pwd=mypwd;Database=mydb;Encrypt=yes;TrustServerCertificate=yes;" == conn_str, "Connection string is incorrect"

def test_autocommit_default(db_connection):
assert db_connection.autocommit is True, "Autocommit should be True by default"
assert db_connection.autocommit is False, "Autocommit should be False by default"

def test_autocommit_setter(db_connection):
db_connection.autocommit = True
Expand Down
Loading