From 02cab0b768b01a6c7b4c8b57362e992d1078c644 Mon Sep 17 00:00:00 2001 From: Random Hacker Date: Thu, 21 Jul 2011 21:52:10 +0200 Subject: webapp: 500 werte, native sqL --- bin/ebus_dump.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bin/ebus_dump.py') 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: -- cgit v1.2.1