modify alert sql
This commit is contained in:
parent
0cd09c02de
commit
eb4a7213fd
|
@ -70,7 +70,7 @@ def create_consumer():
|
||||||
print(f"Create consumer successfully, host: {host}:{port}, groupId: {groupId}, clientId: {clientId}");
|
print(f"Create consumer successfully, host: {host}:{port}, groupId: {groupId}, clientId: {clientId}");
|
||||||
return consumer
|
return consumer
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(f"Failed to create websocket consumer, host: {host}:{port} ; ErrMessage:{err}");
|
print(f"Failed to create native consumer, host: {host}:{port} ; ErrMessage:{err}");
|
||||||
raise err
|
raise err
|
||||||
# ANCHOR_END: create_consumer
|
# ANCHOR_END: create_consumer
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ def prepareMeta():
|
||||||
VALUES (NOW + 1a, 10.30000, 218, 0.25000)
|
VALUES (NOW + 1a, 10.30000, 218, 0.25000)
|
||||||
"""
|
"""
|
||||||
affectedRows = conn.execute(sql)
|
affectedRows = conn.execute(sql)
|
||||||
print(f"inserted into {affectedRows} rows to power.meters successfully.")
|
print(f"Inserted into {affectedRows} rows to power.meters successfully.")
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(f"Failed to prepareMeta ErrMessage:{err}")
|
print(f"Failed to prepareMeta ErrMessage:{err}")
|
||||||
|
@ -95,10 +95,10 @@ def seek_offset(consumer):
|
||||||
print(
|
print(
|
||||||
f"vg_id: {assign.vg_id()}, offset: {assign.offset()}, begin: {assign.begin()}, end: {assign.end()}")
|
f"vg_id: {assign.vg_id()}, offset: {assign.offset()}, begin: {assign.begin()}, end: {assign.end()}")
|
||||||
consumer.seek(topic, assign.vg_id(), assign.begin())
|
consumer.seek(topic, assign.vg_id(), assign.begin())
|
||||||
print("assignment seek to beginning successfully");
|
print("Assignment seek to beginning successfully");
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(f"seek example failed; ErrMessage:{err}")
|
print(f"Seek example failed; ErrMessage:{err}")
|
||||||
raise err
|
raise err
|
||||||
# ANCHOR_END: assignment
|
# ANCHOR_END: assignment
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ def seek_offset(consumer):
|
||||||
def subscribe(consumer):
|
def subscribe(consumer):
|
||||||
try:
|
try:
|
||||||
consumer.subscribe([topic])
|
consumer.subscribe([topic])
|
||||||
print("subscribe topics successfully")
|
print("Subscribe topics successfully")
|
||||||
for i in range(50):
|
for i in range(50):
|
||||||
records = consumer.poll(timeout=1.0)
|
records = consumer.poll(timeout=1.0)
|
||||||
if records:
|
if records:
|
||||||
|
@ -134,7 +134,7 @@ def commit_offset(consumer):
|
||||||
|
|
||||||
# after processing the data, commit the offset manually
|
# after processing the data, commit the offset manually
|
||||||
consumer.commit(records)
|
consumer.commit(records)
|
||||||
print("commit offset manually successfully.");
|
print("Commit offset manually successfully.");
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(f"Failed to poll data, ErrMessage:{err}")
|
print(f"Failed to poll data, ErrMessage:{err}")
|
||||||
|
@ -147,7 +147,7 @@ def commit_offset(consumer):
|
||||||
def unsubscribe(consumer):
|
def unsubscribe(consumer):
|
||||||
try:
|
try:
|
||||||
consumer.unsubscribe()
|
consumer.unsubscribe()
|
||||||
print("consumer unsubscribed successfully.");
|
print("Consumer unsubscribed successfully.");
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(f"Failed to unsubscribe consumer. ErrMessage:{err}")
|
print(f"Failed to unsubscribe consumer. ErrMessage:{err}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue