This directory contains benchmark scripts for testing the performance of various database operations using pyodbc and mssql_python. The goal is to evaluate and compare the performance of these libraries for common database operations.
- To measure the efficiency of
pyodbcandmssql_pythonin handling database operations. - To identify performance bottlenecks and optimize database interactions.
- To ensure the reliability and scalability of the libraries under different workloads.
-
Set Up the Environment Variable:
- Ensure you have a running SQL Server instance.
- Set the
DB_CONNECTION_STRINGenvironment variable with the connection string to your database. For example:set DB_CONNECTION_STRING=Server=your_server;Database=your_database;UID=your_user;PWD=your_password;
-
Install Richbench - Benchmarking Tool:
- Install richbench :
pip install richbench
- Install richbench :
-
Run the Benchmarks:
- Execute richbench from the parent folder (mssql-python) :
Results will be displayed in the terminal with detailed performance metrics.
richbench benchmarks
- Execute richbench from the parent folder (mssql-python) :
- Comprehensive Benchmarks: Includes SELECT, INSERT, UPDATE, DELETE, complex queries, stored procedures, and transaction handling.
- Error Handling: Each benchmark function is wrapped with error handling to ensure smooth execution.
- Progress Messages: Clear progress messages are printed during execution for better visibility.
- Automated Setup and Cleanup: The script automatically sets up and cleans up the database environment before and after the benchmarks.
- Ensure the database user has the necessary permissions to create and drop tables and stored procedures.
- The script uses permanent tables prefixed with
perfbenchmark_for benchmarking purposes. - A stored procedure named
perfbenchmark_stored_procedureis created and used during the benchmarks.