Using ODBC from Python

Help Contents


You can use Python and ODBC to access data in Fernhill SCADA. This article shows you how to do the following:

  1. Connect to Fernhill SCADA.
  2. Execute an SQL query.
  3. Retrieve the results of the SQL query.

You can find the complete source code for this example in the file, which can be found in the Data Access Examples folder.

Locating the Data Access Examples Folder

Fernhill SCADA places a shortcut to the Data Access Examples on the Windows Start Menu. Use this table to find the shortcut based on the Version of Windows you are using:

Windows VersionShortcut Location
Windows 11
  1. Open the Start menu.
  2. Click All apps
  3. Scroll down and expand Fernhill SCADA Operator Tools.
Windows 10
Windows Server 2022
Windows Server 2019
Windows Server 2016
  1. Open the Start menu.
  2. Scroll down and expand Fernhill SCADA Operator Tools.
Windows 8
Windows Server 2012
  1. Open the Start screen.
  2. Click the down arrow.
  3. Scroll right until you see the section Fernhill SCADA Operator Tools
Windows 7
Windows Server 2008
  1. Click the Start button.
  2. Select All Programs.
  3. Expand the folder Fernhill SCADA Operator Tools.

For Linux distributions, the Data Access Examples can be found here:


Example Code

# Use the pyodbc library to access ODBC
import pyodbc

def queryTagValue( connection, fullTagName ):
    # Create the cursor
    cursor = connection.cursor()

    # execute the statement
    cursor.execute("Select Value From TagDataPointAnalog Where FullName = ?", (fullTagName))

    # get the first row
    row = cursor.fetchone()

    # Print the value
    print( "Value =", row.Value )


print("Connecting to Fernhill SCADA...")

# Selecting the Driver to use avoids us having to set up a DSN
connection = pyodbc.connect( "Driver={Fernhill SCADA};Server=localhost" )

# Run the query
queryTagValue( connection, "PumpStation.TotalCurrent")

Further Information

Fernhill SCADA Structured Query Language (SQL)

To learn about the structured query language (SQL) supported by Fernhill SCADA.

Setting up an ODBC DSN

To learn about configuring ODBC data Source Names.

Using ODBC Connection Strings to Connect to Fernhill SCADA

To learn about the keywords Fernhill SCADA supports in ODBC connection strings.

Fernhill SCADA ODBC Driver

To learn how the Fernhill SCADA ODBC Driver can provide data to other applications.


For the meaning of terms used in Fernhill SCADA.