mirror of
https://github.com/FreeOpcUa/opcua-asyncio
synced 2025-10-29 17:07:18 +08:00
enable sqlite tests
This commit is contained in:
parent
0a5ca1e44c
commit
71c4c56d12
|
|
@ -30,7 +30,7 @@ class HistorySQLite(HistoryStorageInterface):
|
|||
self._loop = loop or get_event_loop()
|
||||
|
||||
async def init(self):
|
||||
self._db = aiosqlite.connect(self._db_file, loop=self._loop)
|
||||
self._db = await aiosqlite.connect(self._db_file, loop=self._loop)
|
||||
|
||||
async def stop(self):
|
||||
await self._db.close()
|
||||
|
|
@ -89,28 +89,24 @@ class HistorySQLite(HistoryStorageInterface):
|
|||
f'THEN MIN(SourceTimestamp) ELSE NULL END FROM "{table}")', (count,), table, node_id)
|
||||
|
||||
async def read_node_history(self, node_id, start, end, nb_values):
|
||||
|
||||
table = self._get_table_name(node_id)
|
||||
start_time, end_time, order, limit = self._get_bounds(start, end, nb_values)
|
||||
cont = None
|
||||
results = []
|
||||
# select values from the database; recreate UA Variant from binary
|
||||
try:
|
||||
rows = await self._execute_sql(
|
||||
f'SELECT * FROM "{table}" WHERE "SourceTimestamp" BETWEEN ? AND ? '
|
||||
f'ORDER BY "_Id" {order} LIMIT ?', (start_time, end_time, limit,)
|
||||
)
|
||||
for row in rows:
|
||||
# rebuild the data value object
|
||||
dv = ua.DataValue(variant_from_binary(Buffer(row[6])))
|
||||
dv.ServerTimestamp = row[1]
|
||||
dv.SourceTimestamp = row[2]
|
||||
dv.StatusCode = ua.StatusCode(row[3])
|
||||
results.append(dv)
|
||||
|
||||
async with self._db.execute(
|
||||
f'SELECT * FROM "{table}" WHERE "SourceTimestamp" BETWEEN ? AND ? '
|
||||
f'ORDER BY "_Id" {order} LIMIT ?', (start_time, end_time, limit,)) as cursor:
|
||||
async for row in cursor:
|
||||
# rebuild the data value object
|
||||
dv = ua.DataValue(variant_from_binary(Buffer(row[6])))
|
||||
dv.ServerTimestamp = row[1]
|
||||
dv.SourceTimestamp = row[2]
|
||||
dv.StatusCode = ua.StatusCode(row[3])
|
||||
results.append(dv)
|
||||
except sqlite3.Error as e:
|
||||
self.logger.error("Historizing SQL Read Error for %s: %s", node_id, e)
|
||||
|
||||
if nb_values:
|
||||
if len(results) > nb_values:
|
||||
cont = results[nb_values].SourceTimestamp
|
||||
|
|
|
|||
|
|
@ -19,13 +19,9 @@ def pytest_generate_tests(metafunc):
|
|||
if 'opc' in metafunc.fixturenames:
|
||||
metafunc.parametrize('opc', ['client', 'server'], indirect=True)
|
||||
elif 'history' in metafunc.fixturenames:
|
||||
#metafunc.parametrize('history', ['dict', 'sqlite'], indirect=True)
|
||||
#FIXME: disable sqlite backend, it breaks
|
||||
metafunc.parametrize('history', ['dict'], indirect=True)
|
||||
metafunc.parametrize('history', ['dict', 'sqlite'], indirect=True)
|
||||
elif 'history_server' in metafunc.fixturenames:
|
||||
#FIXME: disable sqlite backend, it breaks
|
||||
#metafunc.parametrize('history_server', ['dict', 'sqlite'], indirect=True)
|
||||
metafunc.parametrize('history_server', ['dict'], indirect=True)
|
||||
metafunc.parametrize('history_server', ['dict', 'sqlite'], indirect=True)
|
||||
|
||||
|
||||
@pytest.yield_fixture(scope='module')
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user