diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ebus_dump.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/bin/ebus_dump.py b/bin/ebus_dump.py index a437b0d..7507738 100755 --- a/bin/ebus_dump.py +++ b/bin/ebus_dump.py @@ -6,9 +6,18 @@ from ebus.model.sql import ModelBase, EbusSQL, Value from ebus.model.sql import EbusSQL from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker +import logging -engine = create_engine('sqlite:///:memory:', echo=True) -#engine = create_engine("postgresql://yvesf:iii@10.2.2.13:5432/yvesf", echo=True) +logging.basicConfig() + +#logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) +logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) + +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") ModelBase.metadata.create_all(engine) @@ -25,10 +34,13 @@ 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()) MyEbusReader() try: asyncore.loop() except KeyboardInterrupt: - for data in session.query(Value).all(): - print data + pass +# for data in session.query(Value).all(): +# print data |