diff options
Diffstat (limited to 'bin/ebus_dump.py')
-rwxr-xr-x | bin/ebus_dump.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/bin/ebus_dump.py b/bin/ebus_dump.py index 7507738..2d6933c 100755 --- a/bin/ebus_dump.py +++ b/bin/ebus_dump.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding:utf8 -*- import asyncore +import time from ebus import EbusReader from ebus.model.sql import ModelBase, EbusSQL, Value from ebus.model.sql import EbusSQL @@ -17,7 +18,7 @@ logger = logging.getLogger('ebus.dump') logger.setLevel(logging.INFO) #engine = create_engine('sqlite:///:memory:', echo=True) -engine = create_engine("postgresql://jack:iii@localhost:5432/ebus") +engine = create_engine("postgresql:///ebus") ModelBase.metadata.create_all(engine) @@ -34,8 +35,12 @@ class MyEbusReader(EbusReader): def handle_ebus(self,ebus_packet): for field in self.sql.get_values(ebus_packet): session.add(field) - session.commit() - logger.info("committed packet %s" % ebus_packet.name()) + + if int(time.time()) % 4 == 0: + logger.info("COMMIT") + session.commit() + + logger.info("packet %s" % ebus_packet.name()) MyEbusReader() try: |