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

Опубликовано: 26 Февраль 2024
на канале: Tech with Hitch
2,842
17

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


Смотрите видео How to Connect to Microsoft Azure SQL Server with Python (w/ pyodbc) онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Tech with Hitch 26 Февраль 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 2,842 раз и оно понравилось 17 людям.