@@ -6921,62 +6921,6 @@ def test_uuid_insert_with_none(cursor, db_connection):
69216921 cursor .execute (f"DROP TABLE IF EXISTS { table_name } " )
69226922 db_connection .commit ()
69236923
6924- def test_executemany_uuid_insert_and_select (cursor , db_connection ):
6925- """Test inserting multiple UUIDs using executemany and verifying retrieval."""
6926- table_name = "#pytest_uuid_executemany"
6927-
6928- try :
6929- # Drop and create a temporary table for the test
6930- cursor .execute (f"DROP TABLE IF EXISTS { table_name } " )
6931- cursor .execute (f"""
6932- CREATE TABLE { table_name } (
6933- id UNIQUEIDENTIFIER PRIMARY KEY,
6934- description NVARCHAR(50)
6935- )
6936- """ )
6937- db_connection .commit ()
6938-
6939- # Generate data for insertion
6940- data_to_insert = []
6941- uuids_to_check = {}
6942- for i in range (5 ):
6943- new_uuid = uuid .uuid4 ()
6944- description = f"Item { i } "
6945- data_to_insert .append ((new_uuid , description ))
6946- uuids_to_check [description ] = new_uuid
6947-
6948- # Insert all data with a single call to executemany
6949- sql = f"INSERT INTO { table_name } (id, description) VALUES (?, ?)"
6950- cursor .executemany (sql , data_to_insert )
6951- db_connection .commit ()
6952-
6953- # Verify the number of rows inserted
6954- assert cursor .rowcount == 5 , f"Expected 5 rows inserted, but got { cursor .rowcount } "
6955-
6956- # Fetch all data from the table
6957- cursor .execute (f"SELECT id, description FROM { table_name } " )
6958- rows = cursor .fetchall ()
6959-
6960- # Verify the number of fetched rows
6961- assert len (rows ) == len (data_to_insert ), "Number of fetched rows does not match."
6962-
6963- # Verify each fetched row's data and type
6964- for row in rows :
6965- retrieved_uuid , retrieved_desc = row
6966-
6967- # Assert the type is correct
6968- assert isinstance (retrieved_uuid , uuid .UUID ), f"Expected uuid.UUID, got { type (retrieved_uuid )} "
6969-
6970- # Assert the value matches the original data
6971- expected_uuid = uuids_to_check .get (retrieved_desc )
6972- assert expected_uuid is not None , f"Retrieved description '{ retrieved_desc } ' was not in the original data."
6973- assert retrieved_uuid == expected_uuid , f"UUID mismatch for '{ retrieved_desc } ': expected { expected_uuid } , got { retrieved_uuid } "
6974-
6975- finally :
6976- # Clean up the temporary table
6977- cursor .execute (f"DROP TABLE IF EXISTS { table_name } " )
6978- db_connection .commit ()
6979-
69806924def test_close (db_connection ):
69816925 """Test closing the cursor"""
69826926 try :
0 commit comments