@@ -7146,6 +7146,62 @@ def test_extreme_uuids(cursor, db_connection):
71467146 cursor .execute (f"DROP TABLE IF EXISTS { table_name } " )
71477147 db_connection .commit ()
71487148
7149+ def test_executemany_uuid_insert_and_select (cursor , db_connection ):
7150+ """Test inserting multiple UUIDs using executemany and verifying retrieval."""
7151+ table_name = "#pytest_uuid_executemany"
7152+
7153+ try :
7154+ # Drop and create a temporary table for the test
7155+ cursor .execute (f"DROP TABLE IF EXISTS { table_name } " )
7156+ cursor .execute (f"""
7157+ CREATE TABLE { table_name } (
7158+ id UNIQUEIDENTIFIER PRIMARY KEY,
7159+ description NVARCHAR(50)
7160+ )
7161+ """ )
7162+ db_connection .commit ()
7163+
7164+ # Generate data for insertion
7165+ data_to_insert = []
7166+ uuids_to_check = {}
7167+ for i in range (5 ):
7168+ new_uuid = uuid .uuid4 ()
7169+ description = f"Item { i } "
7170+ data_to_insert .append ((new_uuid , description ))
7171+ uuids_to_check [description ] = new_uuid
7172+
7173+ # Insert all data with a single call to executemany
7174+ sql = f"INSERT INTO { table_name } (id, description) VALUES (?, ?)"
7175+ cursor .executemany (sql , data_to_insert )
7176+ db_connection .commit ()
7177+
7178+ # Verify the number of rows inserted
7179+ assert cursor .rowcount == 5 , f"Expected 5 rows inserted, but got { cursor .rowcount } "
7180+
7181+ # Fetch all data from the table
7182+ cursor .execute (f"SELECT id, description FROM { table_name } " )
7183+ rows = cursor .fetchall ()
7184+
7185+ # Verify the number of fetched rows
7186+ assert len (rows ) == len (data_to_insert ), "Number of fetched rows does not match."
7187+
7188+ # Verify each fetched row's data and type
7189+ for row in rows :
7190+ retrieved_uuid , retrieved_desc = row
7191+
7192+ # Assert the type is correct
7193+ assert isinstance (retrieved_uuid , uuid .UUID ), f"Expected uuid.UUID, got { type (retrieved_uuid )} "
7194+
7195+ # Assert the value matches the original data
7196+ expected_uuid = uuids_to_check .get (retrieved_desc )
7197+ assert expected_uuid is not None , f"Retrieved description '{ retrieved_desc } ' was not in the original data."
7198+ assert retrieved_uuid == expected_uuid , f"UUID mismatch for '{ retrieved_desc } ': expected { expected_uuid } , got { retrieved_uuid } "
7199+
7200+ finally :
7201+ # Clean up the temporary table
7202+ cursor .execute (f"DROP TABLE IF EXISTS { table_name } " )
7203+ db_connection .commit ()
7204+
71497205def test_decimal_separator_with_multiple_values (cursor , db_connection ):
71507206 """Test decimal separator with multiple different decimal values"""
71517207 original_separator = mssql_python .getDecimalSeparator ()
@@ -10560,6 +10616,7 @@ def test_decimal_separator_calculations(cursor, db_connection):
1056010616
1056110617 # Cleanup
1056210618 cursor .execute ("DROP TABLE IF EXISTS #pytest_decimal_calc_test" )
10619+ db_connection .commit ()
1056310620
1056410621def test_close (db_connection ):
1056510622 """Test closing the cursor"""
0 commit comments