-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How could I access the data from DB in Linux? #2
Comments
Hello Eduardo, I hope this helps. Nicolas |
That error comes from the open62541 code. UA Expert displays the values nevertheless for me. The open62541 files I used in this demo are about 2 years old. From looking at their current codes it seems that the issue is fixed now. You should try to compile with a newer version of the open62541 files. I would like to update it myself but unfortunately I don't have time to do it within the coming 2 weeks :-( |
Hmm, not that I know of. My discovery runs also on port 4840 but succeeds to find the server. Have you checked the console of server that it successfully listens on port 4840? |
Maybe off topic but hope this helps. Feel free to optimize and improve (or change the duration) import curses
import sqlite3
import random
from datetime import datetime, timedelta
try:
sqliteConnection = sqlite3.connect('database.sqlite')
cursor = sqliteConnection.cursor()
print("Successfully Connected to SQLite")
sqlite_select_Query = "select sqlite_version();"
cursor.execute(sqlite_select_Query)
record = cursor.fetchall()
print("SQLite Database Version is: ", record)
table_create_query = "CREATE TABLE `PeriodicValues` (\
`Timestamp` TEXT NOT NULL, \
`MeasuringPointID` INTEGER NOT NULL,\
`Value` REAL NOT NULL, \
PRIMARY KEY(`Timestamp`,`MeasuringPointID`) \
)"
cursor.execute(table_create_query)
i = 1
now = datetime.now()
while i < 131400:
x = random.uniform(1.1,100.5)
dateincrement = now - timedelta(minutes=i)
insert_query = """INSERT INTO "main"."PeriodicValues" ("Timestamp", "MeasuringPointID", "Value") VALUES ('""" + dateincrement.strftime("%Y-%m-%d %H:%M:%S") + """', '1', '""" + str(x) + """');"""
count = cursor.execute(insert_query)
sqliteConnection.commit()
i += 1
cursor.close()
except sqlite3.Error as error:
print("Error while connecting to sqlite", error)
finally:
if sqliteConnection:
sqliteConnection.close()
print("The SQLite connection is closed") |
For those reading this now, please be aware that @happybruce successfully ported this code to Linux/CMake some time ago. I think this should resolve this issue as well. |
Hello @nicolasr75,
First of all, thank you for your contribution to OPCUA server accessing DB. It's a great work!
I'm trying to use your demo in architecture Linux (Ubuntu 16.04LTS). However, I'd some problems.
I'm using UAExpert like client with bounds disabled.
The server was compiled with following changes.
Changes in SQLiteBackend.h :
I also change nothing in DB.
I used "gcc -o opcuatest open62541.c sqlite3.c SQLiteBackend.h OpcUATest.cpp -pthread -ldl -lstdc++" to compile too.
Well, I would like to know how I can access the data from DB following this scenario.
"myDoubleValue" is available to visualize.
Are there some procedure that missed?
Attached UAExpert window.
Best regards
Eduardo Afonso
The text was updated successfully, but these errors were encountered: