How to Connect to Microsoft Azure SQL Server with Python (w/ pyodbc)

Tech with Hitch
Tech with Hitch
1.2 هزار بار بازدید - 5 ماه پیش - I will teach you how
I will teach you how to connect to your Azure Microsoft SQL Server using python pyodbc. We will pip install pyodbc and then build a cnxn_str

The python code will look something like this:

import pyodbc

cnxn_str = (
   'DRIVER={ODBC Driver 17 for SQL Server};'
   'SERVER=your_server_name.database.windows.net;'
   'DATABASE=your_database_name;'
   'UID=your_username;'
   'PWD=your_password'
)

conn = pyodbc.connect(cnxn_str)
cursor = conn.cursor()
cursor.execute("SELECT TOP 10 * FROM your_table")
rows = cursor.fetchall()
cursor.close()
conn.close()

#microsoftazure #azure #sqlserver #pythontutorial
5 ماه پیش در تاریخ 1402/12/07 منتشر شده است.
1,214 بـار بازدید شده
... بیشتر