Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
e961b9a1
Commit
e961b9a1
authored
May 09, 2016
by
zerox1212
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Python 2.7 Support
Handle binary objects to be stored in the database better.
parent
8c3f0a17
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
opcua/server/history_sql.py
opcua/server/history_sql.py
+10
-5
No files found.
opcua/server/history_sql.py
View file @
e961b9a1
...
...
@@ -10,7 +10,10 @@ import sqlite3
class
HistorySQLite
(
HistoryStorageInterface
):
"""
very minimal history backend storing data in SQLite database
history backend which stores data values and object events in a SQLite database
this backend is intended to only be accessed via OPC UA, therefore all UA Variants saved in
the history database are in binary format (SQLite BLOBs)
note that PARSE_DECLTYPES is active so certain data types (such as datetime) will not be BLOBs
"""
def
__init__
(
self
,
path
=
"history.db"
):
...
...
@@ -61,7 +64,7 @@ class HistorySQLite(HistoryStorageInterface):
datavalue
.
StatusCode
.
value
,
str
(
datavalue
.
Value
.
Value
),
datavalue
.
Value
.
VariantType
.
name
,
datavalue
.
Value
.
to_binary
(
)
sqlite3
.
Binary
(
datavalue
.
Value
.
to_binary
()
)
)
)
except
sqlite3
.
Error
as
e
:
...
...
@@ -118,7 +121,8 @@ class HistorySQLite(HistoryStorageInterface):
# select values from the database; recreate UA Variant from binary
try
:
for
row
in
_c_read
.
execute
(
'SELECT * FROM "{tn}" WHERE "ServerTimestamp" BETWEEN ? AND ? '
'ORDER BY "_Id" {dir} LIMIT ?'
.
format
(
tn
=
table
,
dir
=
order
),
(
start_time
,
end_time
,
limit
,)):
'ORDER BY "_Id" {dir} LIMIT ?'
.
format
(
tn
=
table
,
dir
=
order
),
(
start_time
,
end_time
,
limit
,)):
# rebuild the data value object
dv
=
ua
.
DataValue
(
ua
.
Variant
.
from_binary
(
Buffer
(
row
[
6
])))
...
...
@@ -278,7 +282,7 @@ class HistorySQLite(HistoryStorageInterface):
for
field
,
variant
in
ev_variant_dict
.
items
():
placeholders
.
append
(
'?'
)
ev_fields
.
append
(
field
)
ev_variant_binaries
.
append
(
variant
.
to_binary
(
))
ev_variant_binaries
.
append
(
sqlite3
.
Binary
(
variant
.
to_binary
()
))
return
self
.
_list_to_sql_str
(
ev_fields
),
self
.
_list_to_sql_str
(
placeholders
,
False
),
tuple
(
ev_variant_binaries
)
...
...
@@ -298,7 +302,8 @@ class HistorySQLite(HistoryStorageInterface):
name
=
select_clause
.
BrowsePath
[
0
].
Name
s_clauses
.
append
(
name
)
except
AttributeError
:
self
.
logger
.
error
(
'Historizing SQL OPC UA Select Clauses Error for node %s'
,
source_id
)
self
.
logger
.
warning
(
'Historizing SQL OPC UA Select Clause Warning for node %s,'
' Clause: %s:'
,
source_id
,
select_clause
)
# remove select clauses that the event type doesn't have; SQL will error because the column doesn't exist
clauses
=
[
x
for
x
in
s_clauses
if
self
.
_check
(
source_id
,
x
)]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment