This section provides a walk-through to writing ODBC data access code to SQL Server in Python, using the pyodbc module.
Connecting from Python
See Getting Started for the prerequisite information you need to deploy the driver and configure the connection to SQL Server.
Use pyodbc functions to execute SQL on SQL Server:
- See Querying Data to execute SELECT statements and iterate over the results.
- See Updating Data to execute other SQL data manipulation statements.
- See Parameterized Statements to execute parameterized statements. Parameterized statements provide a means to efficiently execute queries more than once and to mitigate SQL injection attacks.
Executing Stored Procedures
See Executing Stored Procedures to execute stored procedures as SQL statements.