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

Поделиться
HTML-код
  • Опубликовано: 25 авг 2024
  • 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

Комментарии •