Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Join our "Ask Me About" community webinar on May 20th at 9 AM CET and 5 PM CET to explore cybersecurity and monitoring for Data Center and edge IT. Learn about market trends, cutting-edge technologies, and best practices from industry experts.
Register and secure your Critical IT infrastructure

how to connect to geoscada database from python

EcoStruxure Geo SCADA Expert Forum

Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • Remote Operations
  • EcoStruxure Geo SCADA Expert Forum
  • how to connect to geoscada database from python
Options
  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
sbeadle
Kirk sbeadle Kirk
307
AndrewScott
Admiral AndrewScott
96
BevanWeiss
Spock BevanWeiss
90
AdamWoodlandToo
Lt. Commander AdamWoodlandToo
36
View All
Related Products
product field
Schneider Electric
EcoStruxure™ Geo SCADA Expert

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to EcoStruxure Geo SCADA Expert Forum
Solved
Anonymous user
Not applicable

Posted: ‎2021-06-10 06:57 AM . Last Modified: ‎2023-05-03 12:03 AM

0 Likes
8
4231
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2021-06-10 06:57 AM . Last Modified: ‎2023-05-03 12:03 AM

how to connect to geoscada database from python

Hi,

 

could you help me with the connection to Geoscada database from python?

 

I want to create a python script that can read and write values to variables inside the Geoscada database (local geoscada server). I think I can use python library pyodbc, but I cannot find documentation or guide on how to do it. Is it possible? if yes, how to do it? And if not, is there any solution how to manipulate DB from python (or from another language)?? 

 

Thank you very much!

 

 

Labels
  • Labels:
  • Logic
  • SCADA
  • Scripting
  • ViewX
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
sbeadle
Kirk sbeadle Kirk
Kirk

Posted: ‎2021-06-11 12:29 AM

In response to BevanWeiss
1 Like
1
4210
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2021-06-11 12:29 AM

Hi,

The best way to connect is to use the pythonnet library to connect to the Geo SCADA .Net client.

This is (was when I last looked) available for python up to v3.8).

 

Example:

# Import .Net runtime support - needs "pip install pythonnet"
import clr

# Get Geo SCADA Library (could use the namespace if the dll is on PATH)
CS = clr.AddReference( "c:\Program Files\Schneider Electric\ClearSCADA\ClearSCADA.Client.dll" )
import ClearScada.Client as CSClient 

# Create node and connect, then log in. (Could read net parameters from SYSTEMS.XML)
node = CSClient.ServerNode( CSClient.ConnectionType.Standard, "127.0.0.1", 5481 )
connection = CSClient.Simple.Connection( "Utility" )
connection.Connect( node )
connection.LogOn( "AdminExample", "AdminExample" )

# instance a template
P = connection.GetObject("Test") #parent
T = connection.GetObject("Test.Test Bulk Data.Ten Points") # A template
I = P.CreateInstance(T, "New Instance") # Create an instance

# set string point value
P = connection.GetObject("Test.New String Point") # A string point
P.InvokeMethod("CurrentValue", "fred" )

# get object children
FieldDevice = connection.GetObject("Test")
Children = FieldDevice.GetChildren("CDBPoint","")
for value in Children:
    print(value.FullName)

# set an object's Geo Location
FieldDevice = connection.GetObject("SELogger.2820015789 DLLTE4-SA.Logger" )
GeoAgg = FieldDevice.Aggregates["GISLocationSource"];
print( GeoAgg.Enabled);
GeoAgg.ClassName = "CGISLocationSrcDynamic"
print( GeoAgg.ClassName);
GeoAgg["Latitude"] = 3
GeoAgg["Longitude"] = 4

# Find and set internal point values in history
pointObject = connection.GetObject("Example Projects.Oil and Gas.Transportation.Graphics.End Station.Valve 3.Position Control" )
for i in range(1,100,30):
    pointObject.InvokeMethod("CurrentValue", i )
    print( "Point set to: " + str(pointObject.GetProperty("CurrentValue" ) ) )

# Find a historic point      
pointObject2 = connection.GetObject("Example Projects.Oil and Gas.Transportation.Inflow Computer.GasFlow" )
from System import DateTime # To support .Net date/time
# Historic arguments are start, end, index(=0), maxrecords, forwards=true, reason="All"
hisStart = DateTime( 2021,1,19,0,0,0 )
hisEnd =   DateTime( 2021,1,20,0,0,0 )
hisArgs = [ hisStart, hisEnd, 0, 100, True, "All" ]
# Call methods to get values and times. Could also read quality, or use .ProcessedValue to get fixed interval data
hisValues = pointObject2.InvokeMethod("Historic.RawValues", hisArgs )
hisQualities = pointObject2.InvokeMethod("Historic.RawQualities", hisArgs )
hisTimeStamps = pointObject2.InvokeMethod("Historic.RawTimestamps", hisArgs )
for i in range( hisTimeStamps.Length):
    print( hisTimeStamps[i], hisValues[i], hisQualities[i] )

Please mark as a solution!

See Answer In Context

  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

Replies 8
tfranklin
Commander tfranklin
Commander

Posted: ‎2021-06-10 10:15 AM

0 Likes
0
4224
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2021-06-10 10:15 AM

You're on the right track with accessing it via ODBC when using python.  I've written a few things against it for extracting history and doing data frames and such in the past and it works really well.  Below is a sample on how to connect, run a query, and iterate through it.  This should be enough to get you started.

 

import pyodbc
#connect to the DSN
cnxn = pyodbc.connect('DSN=DSNNAMEHERE;UID=USERNAMEHERE;PWD=PASSWORDHERE')
cursor = cnxn.cursor()
#execute the query.  the same approach would be used for writing updates to update values.
cursor.execute("SELECT TOP(10) Id,FullName FROM CDBPOINT ORDER BY FullName ASC")
#build the record set
points = cursor.fetchall()
#loop the recordset
for point in points:
    #do something here
    #data can be accessed as follows
    pId = point.Id
    pFullName = point.FullName
    print(str(pId) + ';' + pFullName)
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

BevanWeiss
Spock BevanWeiss
Spock

Posted: ‎2021-06-10 05:37 PM . Last Modified: ‎2023-04-25 03:19 AM

0 Likes
2
4216
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2021-06-10 05:37 PM . Last Modified: ‎2023-04-25 03:19 AM

There is the ODBC way as mentioned previously... I haven't tried this from Python, but I'm sure there would be some way to use the OLE / COM interface also (possibly even the .NET interface.. assuming there is some Python library to deal with managed .NET APIs).

 

On the about to be moved TProjects space there is a collection of (short) documents around using the Automation Interface from various languages.  Perl isn't Python of course... but they possibly have similar traps around threading model, and needing to go via OLE to obtain an object reference... so it might be helpful (or not) 

https://community.se.com/t5/Geo-SCADA-Knowledge-Base/Resource-Center-Home/ba-p/279133

 


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

sbeadle
Kirk sbeadle Kirk
Kirk

Posted: ‎2021-06-11 12:29 AM

In response to BevanWeiss
1 Like
1
4211
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2021-06-11 12:29 AM

Hi,

The best way to connect is to use the pythonnet library to connect to the Geo SCADA .Net client.

This is (was when I last looked) available for python up to v3.8).

 

Example:

# Import .Net runtime support - needs "pip install pythonnet"
import clr

# Get Geo SCADA Library (could use the namespace if the dll is on PATH)
CS = clr.AddReference( "c:\Program Files\Schneider Electric\ClearSCADA\ClearSCADA.Client.dll" )
import ClearScada.Client as CSClient 

# Create node and connect, then log in. (Could read net parameters from SYSTEMS.XML)
node = CSClient.ServerNode( CSClient.ConnectionType.Standard, "127.0.0.1", 5481 )
connection = CSClient.Simple.Connection( "Utility" )
connection.Connect( node )
connection.LogOn( "AdminExample", "AdminExample" )

# instance a template
P = connection.GetObject("Test") #parent
T = connection.GetObject("Test.Test Bulk Data.Ten Points") # A template
I = P.CreateInstance(T, "New Instance") # Create an instance

# set string point value
P = connection.GetObject("Test.New String Point") # A string point
P.InvokeMethod("CurrentValue", "fred" )

# get object children
FieldDevice = connection.GetObject("Test")
Children = FieldDevice.GetChildren("CDBPoint","")
for value in Children:
    print(value.FullName)

# set an object's Geo Location
FieldDevice = connection.GetObject("SELogger.2820015789 DLLTE4-SA.Logger" )
GeoAgg = FieldDevice.Aggregates["GISLocationSource"];
print( GeoAgg.Enabled);
GeoAgg.ClassName = "CGISLocationSrcDynamic"
print( GeoAgg.ClassName);
GeoAgg["Latitude"] = 3
GeoAgg["Longitude"] = 4

# Find and set internal point values in history
pointObject = connection.GetObject("Example Projects.Oil and Gas.Transportation.Graphics.End Station.Valve 3.Position Control" )
for i in range(1,100,30):
    pointObject.InvokeMethod("CurrentValue", i )
    print( "Point set to: " + str(pointObject.GetProperty("CurrentValue" ) ) )

# Find a historic point      
pointObject2 = connection.GetObject("Example Projects.Oil and Gas.Transportation.Inflow Computer.GasFlow" )
from System import DateTime # To support .Net date/time
# Historic arguments are start, end, index(=0), maxrecords, forwards=true, reason="All"
hisStart = DateTime( 2021,1,19,0,0,0 )
hisEnd =   DateTime( 2021,1,20,0,0,0 )
hisArgs = [ hisStart, hisEnd, 0, 100, True, "All" ]
# Call methods to get values and times. Could also read quality, or use .ProcessedValue to get fixed interval data
hisValues = pointObject2.InvokeMethod("Historic.RawValues", hisArgs )
hisQualities = pointObject2.InvokeMethod("Historic.RawQualities", hisArgs )
hisTimeStamps = pointObject2.InvokeMethod("Historic.RawTimestamps", hisArgs )
for i in range( hisTimeStamps.Length):
    print( hisTimeStamps[i], hisValues[i], hisQualities[i] )

Please mark as a solution!

  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

AarondV
Crewman AarondV
Crewman

Posted: ‎2024-07-03 12:43 AM

In response to sbeadle
0 Likes
0
1505
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-07-03 12:43 AM

I assume this solution will only work for a local GeoSCADA server? Or is there a way to adapt this for accessing a server that is not local?

Or should I use the pyodbc library for a non-local SQL database?

Reply

Link copied. Please paste this link to share this article on your social media post.

AndrewScott
Admiral AndrewScott
Admiral

Posted: ‎2024-07-03 03:40 AM

1 Like
0
1503
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-07-03 03:40 AM

You should be able to simply change the IP address from localhost to the IP address or name of the remote server in the following line:

node = CSClient.ServerNode( CSClient.ConnectionType.Standard, "127.0.0.1", 5481 )

 


Andrew Scott, R&D Principal Technologist, AVEVA
Reply

Link copied. Please paste this link to share this article on your social media post.

AarondV
Crewman AarondV
Crewman

Posted: ‎2024-07-03 08:47 PM

0 Likes
2
1472
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-07-03 08:47 PM

OK thanks @AndrewScott 

The thought I had was that it wouldn't work because you need access to the .dll file which needs to be stored locally? I am trying to make this work on a machine which doesn't have GeoSCADA installed.

# Get Geo SCADA Library (could use the namespace if the dll is on PATH)
CS = clr.AddReference( "c:\Program Files\Schneider Electric\ClearSCADA\ClearSCADA.Client.dll" )

 

From what I can see the solution by @tfranklin wouldn't need to have GeoSCADA installed locally.

Reply

Link copied. Please paste this link to share this article on your social media post.

AndrewScott
Admiral AndrewScott
Admiral

Posted: ‎2024-07-04 02:17 AM

In response to AarondV
1 Like
0
1455
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-07-04 02:17 AM

@AarondV you will need to locally install the Geo SCADA data access components for either the .NET client API (using "pythonnet") or for ODBC (using "pyodbc"). For ODBC you'll also need to setup an ODBC data source name (DSN).

 

For details on installing the data access components, see Install Data Access Components on a Third-Party ODBC Client in the help.


Andrew Scott, R&D Principal Technologist, AVEVA
Reply

Link copied. Please paste this link to share this article on your social media post.

jabradf
Crewman jabradf
Crewman

Posted: ‎2024-10-29 03:47 PM

In response to AarondV
0 Likes
0
871
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-10-29 03:47 PM

I copied the relevant DLLs locally and I'm able to connect to a remote machine running geo scada to perform some functions.

Reply

Link copied. Please paste this link to share this article on your social media post.

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of