|
1 | 1 | # Microsoft Python Driver for SQL Server |
2 | | - |
| 2 | + |
3 | 3 | **mssql-python** is a Python driver for Microsoft SQL Server and the Azure SQL family of databases. It leverages Direct Database Connectivity (DDBC) that enables direct connections to SQL Server without requiring an external driver manager. Designed to comply with the [DB API 2.0](https://peps.python.org/pep-0249/) specification, this driver also introduces Pythonic enhancements for improved usability and functionality. It supports a full range of database operations, including connection management, query execution, and transaction handling. |
4 | | - |
| 4 | + |
| 5 | +The driver is compatible with all the Python versions >= 3.10 |
| 6 | + |
5 | 7 | [Documentation](https://github.com/microsoft/mssql-python/wiki) | [Release Notes](https://github.com/microsoft/mssql-python/releases) | [Roadmap](https://github.com/microsoft/mssql-python/blob/main/ROADMAP.md) |
6 | | - |
| 8 | + |
7 | 9 | > **Note:** |
8 | | -> This project is currently in an alpha phase, meaning it is still under active development. We are looking to validate core functionalities and gather initial feedback before a broader public launch. Please use with caution and avoid production environments. |
| 10 | +> This project is currently in Public Preview, meaning it is still under active development. We are working on core functionalities and gathering more feedback before GA. Please use with caution and avoid production environments. |
9 | 11 | > |
10 | 12 | ## Installation |
11 | | - |
| 13 | + |
12 | 14 | mssql-python can be installed with [pip](http://pypi.python.org/pypi/pip) |
13 | 15 | ```bash |
14 | 16 | pip install mssql-python |
15 | 17 | ``` |
16 | 18 | ## Key Features |
17 | | -### Supported Platforms |
18 | | - |
19 | | -Windows |
20 | | - |
| 19 | +### Supported Platforms |
| 20 | + |
| 21 | +Windows and MacOS |
| 22 | + |
21 | 23 | > **Note:** |
22 | | -> Support for macOS and Linux is coming soon |
23 | | -> |
24 | | -
|
| 24 | +> Support for Linux is coming soon |
| 25 | +> |
| 26 | + |
25 | 27 | ### DBAPI v2.0 Compliance |
26 | | - |
| 28 | + |
27 | 29 | The Microsoft **mssql-python** module is designed to be fully compliant with the DB API 2.0 specification. This ensures that the driver adheres to a standardized interface for database access in Python, providing consistency and reliability across different database systems. Key aspects of DBAPI v2.0 compliance include: |
28 | | - |
| 30 | + |
29 | 31 | - **Connection Objects**: Establishing and managing connections to the database. |
30 | 32 | - **Cursor Objects**: Executing SQL commands and retrieving results. |
31 | 33 | - **Transaction Management**: Supporting commit and rollback operations to ensure data integrity. |
32 | 34 | - **Error Handling**: Providing a consistent set of exceptions for handling database errors. |
33 | 35 | - **Parameter Substitution**: Allowing the use of placeholders in SQL queries to prevent SQL injection attacks. |
34 | | - |
| 36 | + |
35 | 37 | By adhering to the DB API 2.0 specification, the mssql-python module ensures compatibility with a wide range of Python applications and frameworks, making it a versatile choice for developers working with Microsoft SQL Server, Azure SQL Database, and Azure SQL Managed Instance. |
36 | | - |
| 38 | + |
37 | 39 | ### Support for Microsoft Entra ID Authentication |
38 | | - |
| 40 | + |
39 | 41 | The Microsoft mssql-python driver enables Python applications to connect to Microsoft SQL Server, Azure SQL Database, or Azure SQL Managed Instance using Microsoft Entra ID identities. It supports various authentication methods, including username and password, Microsoft Entra managed identity, and Integrated Windows Authentication in a federated, domain-joined environment. Additionally, the driver supports Microsoft Entra interactive authentication and Microsoft Entra managed identity authentication for both system-assigned and user-assigned managed identities. |
40 | | - |
| 42 | + |
41 | 43 | ### Enhanced Pythonic Features |
42 | | - |
| 44 | + |
43 | 45 | The driver offers a suite of Pythonic enhancements that streamline database interactions, making it easier for developers to execute queries, manage connections, and handle data more efficiently. |
44 | | - |
| 46 | + |
| 47 | +### Connection Pooling |
| 48 | + |
| 49 | +The Microsoft mssql_python driver provides built-in support for connection pooling, which helps improve performance and scalability by reusing active database connections instead of creating a new connection for every request. |
| 50 | + |
| 51 | + |
45 | 52 | ## Getting Started Examples |
46 | | - |
47 | 53 | Connect to SQL Server and execute a simple query: |
48 | | - |
| 54 | + |
49 | 55 | ```python |
50 | 56 | import mssql_python |
51 | | - |
| 57 | + |
52 | 58 | # Establish a connection |
53 | 59 | # Specify connection string |
54 | 60 | connection_string = "SERVER=<your_server_name>;DATABASE=<your_database_name>;UID=<your_user_name>;PWD=<your_password>;Encrypt=yes;" |
55 | 61 | connection = mssql_python.connect(connection_string) |
56 | | - |
| 62 | + |
57 | 63 | # Execute a query |
58 | 64 | cursor = connection.cursor() |
59 | 65 | cursor.execute("SELECT * from customer") |
60 | 66 | rows = cursor.fetchall() |
61 | | - |
| 67 | + |
62 | 68 | for row in rows: |
63 | 69 | print(row) |
64 | | - |
| 70 | + |
65 | 71 | # Close the connection |
66 | 72 | connection.close() |
67 | | - |
| 73 | + |
68 | 74 | ``` |
69 | | - |
| 75 | + |
70 | 76 | ## Still have questions? |
71 | | - |
| 77 | + |
72 | 78 | Check out our [FAQ](https://github.com/microsoft/mssql-python/wiki/Frequently-Asked-Questions). Still not answered? Create an [issue](https://github.com/microsoft/mssql-python/issues/new/choose) to ask a question. |
73 | | - |
| 79 | + |
74 | 80 | ## Contributing |
75 | | - |
| 81 | + |
76 | 82 | This project welcomes contributions and suggestions. Most contributions require you to agree to a |
77 | 83 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us |
78 | 84 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. |
79 | | - |
| 85 | + |
80 | 86 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide |
81 | 87 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions |
82 | 88 | provided by the bot. You will only need to do this once across all repos using our CLA. |
83 | | - |
| 89 | + |
84 | 90 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). |
85 | 91 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or |
86 | 92 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. |
87 | | - |
| 93 | + |
88 | 94 | ## License |
89 | 95 | The mssql-python driver for SQL Server is licensed under the MIT license, except the dynamic-link libraries (DLLs) in the [libs](https://github.com/microsoft/mssql-python/tree/alphaChanges/mssql_python/libs) folder |
90 | 96 | that are licensed under MICROSOFT SOFTWARE LICENSE TERMS. |
91 | | - |
| 97 | + |
92 | 98 | Please review the [LICENSE](LICENSE) file for more details. |
93 | | - |
| 99 | + |
94 | 100 | ## Trademarks |
95 | | - |
| 101 | + |
96 | 102 | This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft |
97 | 103 | trademarks or logos is subject to and must follow |
98 | 104 | [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). |
99 | 105 | Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. |
100 | | -Any use of third-party trademarks or logos are subject to those third-party's policies. |
| 106 | +Any use of third-party trademarks or logos are subject to those third-party's policies. |
0 commit comments