Connecting from Python

Python supports connectivity to Querona by using the SQL Server ODBC driver and pyodbc package. Querona is compatible with SQL Server ODBC driver v13 and later.

To use the pyodbc package you first have to install it, using PIP for example:

pip install pyodbc

The following example code connects using the compatible SQL Server ODBC v13 driver and integrated authentication:

import pyodbc
conn = pyodbc.connect('Driver={ODBC Driver 13 for SQL Server};'
                      'Server=your-querona-server-name;'
                      'Database=YourDatabaseName;'
                      'Trusted_Connection=yes;')

cursor = conn.cursor()
cursor.execute('SELECT * FROM YourTable')

for row in cursor:
    print(row)

The following example code demonstrates connecting using standard authentication:

import pyodbc
conn = pyodbc.connect('Driver={ODBC Driver 13 for SQL Server};'
                      'Server=your-querona-server-name;'
                      'Database=YourDatabaseName;'
                      'UID=YourUsername;'
                      'PWD=YourPassword;')

cursor = conn.cursor()
cursor.execute('SELECT * FROM YourTable')

for row in cursor:
    print(row)

The “SQL Server” ODBC driver ships with Windows only to support legacy applications and does not support new SQL data types and features introduced since the release of SQL 2005.